@orderly.network/ui-orders 2.0.0-alpha.1

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.
@@ -0,0 +1,64 @@
1
+ import * as react from 'react';
2
+ import { FC } from 'react';
3
+ import * as _orderly_network_types from '@orderly.network/types';
4
+ import { OrderStatus } from '@orderly.network/types';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
+
7
+ declare enum TabType {
8
+ all = "all",
9
+ pending = "pending",
10
+ tp_sl = "tp_sl",
11
+ filled = "filled",
12
+ cancelled = "cancelled",
13
+ rejected = "rejected",
14
+ orderHistory = "orderHistory"
15
+ }
16
+ declare const OrdersWidget: FC<{
17
+ current?: TabType;
18
+ }>;
19
+
20
+ declare const useOrdersScript: (props: {
21
+ current?: TabType;
22
+ }) => {
23
+ current: TabType | undefined;
24
+ };
25
+ type OrdersBuilderState$1 = ReturnType<typeof useOrdersScript>;
26
+
27
+ declare const useOrderListScript: (props: {
28
+ type: TabType;
29
+ ordersStatus?: OrderStatus;
30
+ }) => {
31
+ type: TabType;
32
+ dataSource: any[] | null;
33
+ isLoading: boolean;
34
+ loadMore: () => void;
35
+ cancelOrder: (orderId: number, symbol?: string | undefined) => Promise<any>;
36
+ updateOrder: (orderId: string, order: _orderly_network_types.OrderEntity) => Promise<any>;
37
+ cancelAlgoOrder: (orderId: number, symbol?: string | undefined) => Promise<any>;
38
+ updateAlgoOrder: (orderId: string, order: _orderly_network_types.OrderEntity) => Promise<any>;
39
+ page: number;
40
+ pageSize: number;
41
+ setPage: react.Dispatch<react.SetStateAction<number>>;
42
+ setPageSize: (pageSize: number) => void;
43
+ meta: {
44
+ count: number;
45
+ page: number;
46
+ pageSize: number;
47
+ pageTotal: number;
48
+ };
49
+ onFilter: (filter: {
50
+ name: string;
51
+ value: any;
52
+ }) => void;
53
+ filterItems: any[];
54
+ };
55
+ type OrdersBuilderState = ReturnType<typeof useOrderListScript>;
56
+
57
+ declare const OrderList: FC<OrdersBuilderState>;
58
+
59
+ declare const OrderListWidget: (props: {
60
+ type: TabType;
61
+ ordersStatus?: OrderStatus;
62
+ }) => react_jsx_runtime.JSX.Element;
63
+
64
+ export { OrderList, OrderListWidget, type OrdersBuilderState$1 as OrdersBuilderState, OrdersWidget, TabType, useOrderListScript, useOrdersScript };
@@ -0,0 +1,64 @@
1
+ import * as react from 'react';
2
+ import { FC } from 'react';
3
+ import * as _orderly_network_types from '@orderly.network/types';
4
+ import { OrderStatus } from '@orderly.network/types';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
+
7
+ declare enum TabType {
8
+ all = "all",
9
+ pending = "pending",
10
+ tp_sl = "tp_sl",
11
+ filled = "filled",
12
+ cancelled = "cancelled",
13
+ rejected = "rejected",
14
+ orderHistory = "orderHistory"
15
+ }
16
+ declare const OrdersWidget: FC<{
17
+ current?: TabType;
18
+ }>;
19
+
20
+ declare const useOrdersScript: (props: {
21
+ current?: TabType;
22
+ }) => {
23
+ current: TabType | undefined;
24
+ };
25
+ type OrdersBuilderState$1 = ReturnType<typeof useOrdersScript>;
26
+
27
+ declare const useOrderListScript: (props: {
28
+ type: TabType;
29
+ ordersStatus?: OrderStatus;
30
+ }) => {
31
+ type: TabType;
32
+ dataSource: any[] | null;
33
+ isLoading: boolean;
34
+ loadMore: () => void;
35
+ cancelOrder: (orderId: number, symbol?: string | undefined) => Promise<any>;
36
+ updateOrder: (orderId: string, order: _orderly_network_types.OrderEntity) => Promise<any>;
37
+ cancelAlgoOrder: (orderId: number, symbol?: string | undefined) => Promise<any>;
38
+ updateAlgoOrder: (orderId: string, order: _orderly_network_types.OrderEntity) => Promise<any>;
39
+ page: number;
40
+ pageSize: number;
41
+ setPage: react.Dispatch<react.SetStateAction<number>>;
42
+ setPageSize: (pageSize: number) => void;
43
+ meta: {
44
+ count: number;
45
+ page: number;
46
+ pageSize: number;
47
+ pageTotal: number;
48
+ };
49
+ onFilter: (filter: {
50
+ name: string;
51
+ value: any;
52
+ }) => void;
53
+ filterItems: any[];
54
+ };
55
+ type OrdersBuilderState = ReturnType<typeof useOrderListScript>;
56
+
57
+ declare const OrderList: FC<OrdersBuilderState>;
58
+
59
+ declare const OrderListWidget: (props: {
60
+ type: TabType;
61
+ ordersStatus?: OrderStatus;
62
+ }) => react_jsx_runtime.JSX.Element;
63
+
64
+ export { OrderList, OrderListWidget, type OrdersBuilderState$1 as OrdersBuilderState, OrdersWidget, TabType, useOrderListScript, useOrdersScript };
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ var ui = require('@orderly.network/ui');
4
+ var types = require('@orderly.network/types');
5
+ var uiConnector = require('@orderly.network/ui-connector');
6
+ var utils = require('@orderly.network/utils');
7
+ var react = require('react');
8
+ var hooks = require('@orderly.network/hooks');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+ require('date-fns');
11
+
12
+ var ye=e=>{let{current:t}=e;return {current:t}};var be=e=>e===void 0||e.length===0?e:e.length===1?e.charAt(0).toUpperCase():e.charAt(0).toUpperCase()+e.toLowerCase().slice(1);function Fe(e){if(typeof e.type<"u")return typeof e.type=="string"?[e.type.replace("_ORDER","").toLowerCase()]:[e.type];if(typeof e.algo_type<"u"){let t=new Array;e.algo_type==="POSITIONAL_TP_SL"&&t.push("Position");let r=e.child_orders.find(i=>i.algo_type==="TAKE_PROFIT"&&!!i.trigger_price),o=e.child_orders.find(i=>i.algo_type==="STOP_LOSS"&&!!i.trigger_price);return (r||o)&&t.push(r&&o?"TP/SL":r?"TP":"SL"),t}}function I(e){return e.status===types.OrderStatus.CANCELLED||e.algo_status===types.OrderStatus.CANCELLED}var A=react.createContext({}),Re=e=>{let{cancelOrder:t,editOrder:r,cancelAlgoOrder:o,editAlgoOrder:i}=e,n=hooks.useSymbolsInfo(),u=react.useCallback(async l=>l.algo_order_id!==void 0?"root_algo_order_id"in l&&l.root_algo_order_id!==l.algo_order_id?o(l.root_algo_order_id,l.symbol):o(l.algo_order_id,l.symbol).then(()=>{}):t(l.order_id,l.symbol).then(()=>{}),[]),a=react.useCallback(async(l,c)=>{l.visible_quantity!==void 0?l.visible_quantity===0:l.visible!==void 0?l.visible===0:!1;await ui.modal.sheet({title:"Edit Order",contentClassName:"orderly-edit-order-sheet-content",content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Content"})});},[]),d=react.useCallback((l,c,m)=>{let{min_notional:g}=n[l]();return hooks.checkNotional(c,m,g)},[n]);return jsxRuntime.jsx(A.Provider,{value:{onCancelOrder:u,onEditOrder:a,editOrder:r,editAlgoOrder:i,checkMinNotional:d},children:e.children})};var Me=react.createContext({}),le=()=>react.useContext(Me),Be=e=>{let[t,r]=react.useState(),[o]=hooks.useMutation("/v1/algo/order","DELETE"),[i]=hooks.useMutation("/v1/algo/order","PUT"),n=hooks.useSWRConfig(),{state:u}=hooks.useAccount(),a=react.useMemo(()=>hooks.unstable_serialize(()=>["/v1/positions",u.accountId]),[u.accountId]),d=async f=>o(null,{order_id:f.algo_order_id,symbol:f.symbol}),l=async(f,w)=>i({order_id:f.algo_order_id,child_orders:f.child_orders.map(C=>({order_id:C.algo_order_id,quantity:w.order_quantity}))}),c=f=>n.cache.get(a)?.data.rows.find(C=>C.symbol===f),{sl_trigger_price:m,tp_trigger_price:g}=react.useMemo(()=>!("algo_type"in e.order)||!Array.isArray(e.order.child_orders)?{}:hooks.utils.findTPSLFromOrder(e.order),[e.order]);return react.useEffect(()=>{if("algo_type"in e.order){let f=c(e.order.symbol);f&&r(f);}},[e.order.symbol]),jsxRuntime.jsx(Me.Provider,{value:{order:e.order,sl_trigger_price:m,tp_trigger_price:g,onCancelOrder:d,onUpdateOrder:l,getRelatedPosition:c,position:t},children:e.children})};var $e=react.createContext({}),W=()=>react.useContext($e),ze=e=>{let t=hooks.useSymbolsInfo()[e.symbol];return jsxRuntime.jsx($e.Provider,{value:{base_dp:t("base_dp"),quote_dp:t("quote_dp"),base_tick:t("base_tick"),base:t("base"),quote:t("quote"),symbol:e.symbol},children:e.children})};var Q=e=>{let{type:t,base:r,value:o,cancelPopover:i,isSubmitting:n,onConfirm:u}=e,a=react.useMemo(()=>{switch(t){case 0:return `You agree changing the quantity of ${r}-PERP order to `;case 1:return `You agree changing the price of ${r}-PERP order to `;case 2:return `You agree changing the trigger price of ${r}-PERP order to `}},[t]);return jsxRuntime.jsxs("div",{className:"oui-pt-5 oui-relative",children:[jsxRuntime.jsxs("div",{className:"oui-text-base-contrast-54 oui-text-2xs desktop:oui-text-sm",children:[a,jsxRuntime.jsx("span",{className:"oui-text-warning",children:utils.commify(o)}),"."]}),jsxRuntime.jsxs("div",{className:"oui-grid oui-grid-cols-2 oui-gap-2 oui-mt-5",children:[jsxRuntime.jsx(ui.Button,{color:"secondary",onClick:i,disabled:n,children:"Cancel"}),jsxRuntime.jsx(ui.Button,{loading:n,onClick:u,children:"Confirm"})]}),jsxRuntime.jsx("button",{className:"oui-absolute oui-right-0 oui-top-0 oui-text-base-contrast-54",onClick:i,children:jsxRuntime.jsx(ui.CloseIcon,{size:18})})]})};var Y=e=>{let{inputRef:t,dp:r,value:o,setPrice:i,setEditting:n,error:u,handleKeyDown:a,onClick:d,onClose:l,hintInfo:c}=e;return react.useEffect(()=>{let m=t.current;if(m){let g=m.value.length;m.setSelectionRange(g,g);}n(!0);},[]),jsxRuntime.jsx(ui.Tooltip,{content:c,open:(c?.length||0)>0,children:jsxRuntime.jsx(ui.Input,{ref:t,type:"text",size:"sm",formatters:[ui.inputFormatter.numberFormatter,ui.inputFormatter.dpFormatter(r)],value:o,onValueChange:m=>i(m),helpText:u,onClick:m=>{m.stopPropagation(),m.preventDefault();},onKeyDown:a,autoFocus:!0,classNames:{root:"oui-bg-base-700 oui-px-2 oui-py-1 oui-rounded",input:"oui-pr-2"},suffix:jsxRuntime.jsx("button",{onClick:d,children:jsxRuntime.jsx(ui.CheckIcon,{size:18,color:"white",opacity:1,className:"oui-cursor-pointer oui-opacity-50 hover:oui-opacity-100"})})})})};var Oe=e=>{let{order:t}=e,[r,o]=react.useState(t.quantity.toString()),[i,n]=react.useState(!1);react.useEffect(()=>{O(t.quantity.toString());},[e.order.quantity]);let[u,a]=react.useState(!1),[d,l]=react.useState(),{editOrder:c,editAlgoOrder:m,checkMinNotional:g}=react.useContext(A),{onUpdateOrder:f,position:w}=le(),{base_dp:C,base:E}=W(),O=s=>{o(s);let P=Math.abs(w?.position_qty||0);w&&Number(s)>P?l(`Quantity should be less than position quantity : ${P}`):l(void 0);},x=()=>{a(!1),n(!1);},S=()=>{a(!1),O(t.quantity.toString()),n(!1);},[D,N]=react.useState(!1),M=react.useRef(null),T=()=>{if(d)return;if(Number(r)===Number(t.quantity)){n(!1);return}let s=t.algo_order_id!==void 0?t.trigger_price:t.price;if(s!==null&&t.reduce_only!==!0){let P=g(t.symbol,s,r);if(P){ui.toast.error(P),N(!1),S();return}}a(!0);},b=s=>{s?.stopPropagation(),s?.preventDefault(),T();},v=s=>{s.key==="Enter"&&(s?.stopPropagation(),s?.preventDefault(),T());},ae=react.useCallback(()=>{N(!0);let s={symbol:t.symbol,order_type:t.type,side:t.side,order_price:t.price,order_quantity:r,algo_order_id:t.algo_order_id};if(typeof s.algo_order_id<"u"&&s.order_type==="MARKET"){let{order_price:U,...Pt}=s;s=Pt;}typeof t.reduce_only<"u"&&(s.reduce_only=t.reduce_only),t.order_tag!==void 0&&(s={...s,order_tag:t.order_tag}),t?.visible_quantity===0&&(s.visible_quantity=0),t?.tag!==void 0&&(s.order_tag=t.tag);let P;"algo_type"in t&&t.algo_type===types.AlgoOrderRootType.TP_SL?P=f(t,s):t.algo_order_id!==void 0?P=m(t.algo_order_id.toString(),s):P=c(t.order_id.toString(),s),P.then(U=>{x(),O(r.toString());},U=>{ui.toast.error(U.message),O(t.quantity.toString()),S();}).finally(()=>N(!1));},[r]),se=react.useRef(null),de=s=>{se.current&&!se.current.contains(s.target)&&!u&&S();};react.useEffect(()=>(document.addEventListener("mousedown",de),()=>{document.removeEventListener("mousedown",de);}),[u]);let _=()=>!i||e.disableEdit?jsxRuntime.jsx(Gt,{order:t,quantity:r,setEditing:n,disableEdit:e.disableEdit}):jsxRuntime.jsx(Y,{inputRef:M,dp:C,value:r,setPrice:O,setEditting:n,handleKeyDown:v,onClick:b,onClose:S});return jsxRuntime.jsx(ui.Popover,{open:u,onOpenChange:a,content:jsxRuntime.jsx(Q,{type:0,base:E,value:r,cancelPopover:S,isSubmitting:D,onConfirm:ae}),children:jsxRuntime.jsx("div",{ref:se,children:_()})})},Gt=e=>{let{order:t,quantity:r}=e,o=t.total_executed_quantity;return jsxRuntime.jsxs(ui.Flex,{direction:"row",justify:"start",gap:1,className:ui.cn("oui-max-w-[110px] oui-relative",t.side===types.OrderSide.BUY&&"oui-text-trade-profit",t.side===types.OrderSide.SELL&&"oui-text-trade-loss",I(t)&&"oui-text-base-conrast-20"),onClick:i=>{i.stopPropagation(),i.preventDefault(),e.setEditing(!0);},children:["algo_type"in t&&t.algo_type===types.AlgoOrderRootType.TP_SL?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:o}),jsxRuntime.jsx("span",{children:"/"})]}),jsxRuntime.jsx(ui.Flex,{r:"base",className:ui.cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2"),children:jsxRuntime.jsx(ui.Text,{size:"2xs",children:r})})]})};var ot=e=>{let{order:t}=e,[r,o]=react.useState(t.price?.toString()??"Market"),[i,n]=react.useState(!1),[u,a]=react.useState(!1),d=t?.algo_order_id!==void 0,l=t?.type==="MARKET"&&d,[c,m]=react.useState(!1),{editOrder:g,editAlgoOrder:f,checkMinNotional:w}=react.useContext(A),{base:C,quote_dp:E}=W(),O=()=>{n(!1),a(!1);},x=()=>{n(!1),o(t.price?.toString()??"Market"),a(!1);},S=_=>{if(_?.stopPropagation(),_?.preventDefault(),r===`${t.price}`){a(!1);return}if(t.reduce_only!==!0){let s=w(t.symbol,r,t.quantity);if(s){ui.toast.error(s),m(!1),x();return}}n(!0);},D=_=>{_.key==="Enter"&&S(_);},N=()=>{m(!0);let _=t.order_id,s={order_price:r,order_quantity:t.quantity,symbol:t.symbol,order_type:t.type,side:t.side};typeof t.reduce_only<"u"&&(s.reduce_only=t.reduce_only),t.order_tag!==void 0&&(s={...s,order_tag:t.order_tag}),d&&(_=t.algo_order_id,s={...s,order_id:_,price:r,algo_order_id:_}),t?.visible_quantity===0&&(s.visible_quantity=0),t.tag!==void 0&&(s.order_tag=t.tag);let P;t.algo_order_id!==void 0?P=f(t.algo_order_id.toString(),s):P=g(t.order_id.toString(),s),P.then(U=>{O(),o(r);},U=>{ui.toast.error(U.message),o(t.price.toString()),x();}).finally(()=>m(!1));},M=react.useRef(null),T=hooks.useSymbolPriceRange(t.symbol,t.side,d?t.trigger_price:void 0),b=react.useMemo(()=>!T||l||!u?"":Number(r)>T.max?`Price can not be greater than ${T.max} USDC.`:Number(r)<T.min?`Price can not be less than ${T.min} USDC.`:"",[l,u,T,r]);react.useEffect(()=>{e.order.price&&o(`${e.order.price}`);},[e.order.price]);let v=react.useRef(null),ae=_=>{v.current&&!v.current.contains(_.target)&&!i&&x();};if(react.useEffect(()=>(document.addEventListener("mousedown",ae),()=>{document.removeEventListener("mousedown",ae);}),[i]),t.algo_order_id&&t.type=="MARKET"||r==="Market")return jsxRuntime.jsx("span",{children:"Market"});let de=()=>!u||e.disableEdit?jsxRuntime.jsx(or,{order:t,price:r,setEditing:a,disableEdit:e.disableEdit}):jsxRuntime.jsx(Y,{inputRef:M,dp:E,value:r,setPrice:o,setEditting:a,handleKeyDown:D,onClick:S,onClose:x,hintInfo:b});return jsxRuntime.jsx(ui.Popover,{open:i,onOpenChange:n,content:jsxRuntime.jsx(Q,{type:1,base:C,value:r,cancelPopover:x,isSubmitting:c,onConfirm:N}),children:jsxRuntime.jsx("div",{ref:v,children:de()})})},or=e=>{let{order:t,price:r}=e;return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold",I(t)&&"oui-text-base-conrast-20"),onClick:o=>{o.stopPropagation(),o.preventDefault(),e.setEditing(!0);},children:jsxRuntime.jsx(ui.Flex,{r:"base",className:ui.cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2"),children:jsxRuntime.jsx(ui.Text,{size:"2xs",children:utils.commifyOptional(r)})})})};var lt=e=>{let{order:t}=e,[r,o]=react.useState("");react.useEffect(()=>{o(t.trigger_price?.toString()??"0");},[t.trigger_price]);let i=t?.algo_order_id!==void 0,[n,u]=react.useState(!1),[a,d]=react.useState(!1),[l,c]=react.useState(!1),{editAlgoOrder:m,checkMinNotional:g}=react.useContext(A),{base:f,quote_dp:w}=W(),C=()=>{u(!1),d(!1);},E=()=>{o(t.trigger_price?.toString()??"0"),u(!1),d(!1);},O=react.useRef(null),x=b=>{O.current&&!O.current.contains(b.target)&&!n&&E();};react.useEffect(()=>(document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x);}),[n]);let S=b=>{if(b?.stopPropagation(),b?.preventDefault(),d(!1),Number(r)!==Number(t.trigger_price)){if(t.price&&t.reduce_only!==!0){let v=g(t.symbol,t.price,t.quantity);if(v){ui.toast.error(v),c(!1),E();return}}u(!0);}},D=b=>{b.key==="Enter"&&S(b);},N=()=>{c(!0);let b={quantity:t.quantity,trigger_price:r,symbol:t.symbol,algo_order_id:t.algo_order_id};t.order_tag!==void 0&&(b={...b,order_tag:t.order_tag}),m(`${t.algo_order_id}`,b).then(v=>{C(),o(r);},v=>{ui.toast.error(v.message),o(t.trigger_price?.toString()??"--"),E();}).finally(()=>c(!1));},M=react.useRef(null);if(!i)return jsxRuntime.jsx(ui.Text,{children:"--"});let T=()=>!a||e.disableEdit?jsxRuntime.jsx(sr,{order:t,price:r,setEditing:d,disableEdit:e.disableEdit}):jsxRuntime.jsx(Y,{inputRef:M,dp:w,value:r,setPrice:o,setEditting:d,handleKeyDown:D,onClick:S,onClose:E});return jsxRuntime.jsx(ui.Popover,{open:n,onOpenChange:u,content:jsxRuntime.jsx(Q,{type:2,base:f,value:r,cancelPopover:E,isSubmitting:l,onConfirm:N}),children:jsxRuntime.jsx("div",{ref:O,children:T()})})},sr=e=>{let{order:t,price:r}=e;return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold",I(t)&&"oui-text-base-conrast-20"),onClick:o=>{o.stopPropagation(),o.preventDefault(),e.setEditing(!0);},children:jsxRuntime.jsx(ui.Flex,{r:"base",className:ui.cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2"),children:jsxRuntime.jsx(ui.Text,{size:"2xs",children:r})})})};var Se=e=>{let{order:t}=e,{onCancelOrder:r}=react.useContext(A),[o,i]=react.useState(!1);return jsxRuntime.jsx(ui.Button,{size:"sm",variant:"outlined",color:"secondary",onClick:n=>{r&&(n.preventDefault(),n.stopPropagation(),i(!0),r(t).then(u=>u,u=>{ui.toast.error(u.message);}).finally(()=>{i(!1);}));},loading:o,children:"Cancel"})};var ut=e=>{let{record:t}=e,[r,o]=react.useState(!1),[i,{data:n,error:u,reset:a,isMutating:d}]=hooks.useMutation("/v1/order"),l=hooks.useConfig("brokerId"),c=react.useCallback(()=>{o(!1);let m={symbol:t.symbol,order_type:t.type,order_price:t.price,order_quantity:t.quantity,order_amount:t.amount,side:t.side,broker_id:l};Number(t.visible_quantity)<Number(t.quantity)&&(m.visible_quantity=0),typeof t.reduce_only<"u"&&(m.reduce_only=t.reduce_only),i(m);},[]);return jsxRuntime.jsx(ui.Button,{size:"sm",variant:"outlined",color:"secondary",loading:d,disabled:d,onClick:m=>{d||(m.preventDefault(),m.stopPropagation(),c());},children:"Renew"})};var pt=()=>{let{sl_trigger_price:e,tp_trigger_price:t,order:r,position:o}=le();return jsxRuntime.jsx(_r,{stopLossPrice:e,takeProfitPrice:t,direction:"column",order:r,position:o,tooltip:!0})},_r=e=>{let{direction:t="row",order:r,position:o}=e,i=hooks.useSymbolsInfo(),n=react.useMemo(()=>{let d=[];if(!e.tooltip||!r||!o)return;let l=r.quantity;return l===0&&r.child_orders[0].type==="CLOSE_POSITION"&&(l=o.position_qty),e.takeProfitPrice&&d.push(jsxRuntime.jsx(mt,{qty:l,price:e.takeProfitPrice,entryPrice:o.average_open_price,orderSide:r.side,orderType:types.AlgoOrderType.TAKE_PROFIT,symbolInfo:i[r.symbol]()},"tp")),e.stopLossPrice&&d.push(jsxRuntime.jsx(mt,{qty:l,price:e.stopLossPrice,entryPrice:o.average_open_price,orderSide:r.side,orderType:types.AlgoOrderType.STOP_LOSS,symbolInfo:i[r.symbol]()},"sl")),jsxRuntime.jsx("div",{children:d})},[e.takeProfitPrice,e.stopLossPrice,o?.average_open_price,r?.side,r?.quantity,r?.algo_type]),u=react.useMemo(()=>{let d=[];return r?.symbol?(e.takeProfitPrice&&d.push(jsxRuntime.jsx(ui.Text.numeral,{className:ui.cn("oui-text-trade-profit oui-gap-0 oui-decoration-white/20"),rule:"price",precision:i[r.symbol]("quote_dp",2),children:e.takeProfitPrice,prefix:!e.stopLossPrice||t==="column"?jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"TP\xA0-\xA0"}):""},"tp")),e.stopLossPrice&&d.push(jsxRuntime.jsx(ui.Text.numeral,{className:ui.cn("oui-text-trade-loss oui-gap-0 oui-decoration-white/20 "),rule:"price",precision:i[r.symbol]("quote_dp",2),children:e.stopLossPrice,prefix:!e.takeProfitPrice||t==="column"?jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"SL\xA0-\xA0"}):""},"sl")),d.length===0?jsxRuntime.jsx("span",{children:"-"}):(d.length===2&&t==="row"&&d.splice(1,0,jsxRuntime.jsx("span",{children:"/"},"split")),d)):jsxRuntime.jsx("span",{children:"-"})},[e.takeProfitPrice,e.stopLossPrice,r?.symbol]),a=jsxRuntime.jsx("div",{className:ui.cn("oui-inline-flex oui-text-base-contrast-36",e.direction==="column"?"oui-flex-col":"oui-flex-row oui-gap-1",e.className),children:u});return e.tooltip?jsxRuntime.jsx(ui.Tooltip,{content:n,children:a}):a},mt=e=>{let{qty:t,price:r,entryPrice:o,orderSide:i,orderType:n,symbolInfo:u}=e,a=hooks.utils.priceToPnl({qty:t,price:r,entryPrice:o,orderSide:i,orderType:n},{symbol:u}),d=n===types.AlgoOrderType.TAKE_PROFIT?"TP":"SL";return jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54 oui-mr-1",children:`${d} PnL:`}),jsxRuntime.jsx(ui.Text.numeral,{rule:"price",className:a===0?"oui-text-base-contrast-36":a>0?"oui-text-trade-profit oui-gap-0":"oui-text-trade-loss oui-gap-0",prefix:jsxRuntime.jsx("span",{children:a===0?"":a>0?"+":"-"}),surfix:jsxRuntime.jsx("span",{className:"oui-text-base-contrast-36 oui-ml-1",children:"USDC"}),children:`${Math.abs(a)}`})]})};var gt=e=>(()=>{switch(e){case"all":return [B({width:130,showType:!0}),$({width:130}),G({width:130,disableEdit:!0,className:"oui-pl-0 oui-pr-0"}),z({width:130,title:"Order price",disableEdit:!0}),pe({width:130}),ft({width:130}),J({width:130}),oe({width:130}),ie({width:130}),K({width:130}),V({width:130}),Ce({width:130})];case"pending":return [B({width:162,showType:!0}),$({width:162}),G({width:162,className:"oui-pr-0"}),z({width:162,className:"oui-pr-0"}),te({width:162,className:"oui-pr-0"}),J({width:162}),K({width:162}),V({width:162}),re({width:162}),Ce({width:162})];case"tp_sl":return [B({width:176,showType:!0}),$({width:176}),kr({width:176}),ft({width:176}),z({width:176,disableEdit:!0}),qr({width:176}),K({width:176}),re({width:176}),Dr({width:176})];case"filled":return [B({width:124}),Fr({width:124}),$({width:124}),G({width:124,disableEdit:!0,className:"oui-pl-0 oui-pr-0"}),z({width:124,title:"Order price",disableEdit:!0}),Rr({width:124}),te({width:124,disableEdit:!0}),J({width:124}),oe({width:124}),ie({width:124}),K({width:124}),V({width:124}),re({width:124})];case"cancelled":return [B({showType:!0,width:124}),$({width:124}),G({width:124,disableEdit:!0,className:"oui-pl-0 oui-pr-0"}),z({width:124,disableEdit:!0}),pe({width:124}),te({width:124,disableEdit:!0}),J({width:124}),oe({width:124}),ie({width:124}),K({width:124}),V({width:124})];case"rejected":return [B({showType:!0,width:124}),$({width:124}),G({width:124,disableEdit:!0,className:"oui-pl-0 oui-pr-0"}),z({width:124,disableEdit:!0}),pe({width:124}),te({width:124,disableEdit:!0}),J({width:124}),oe({width:124}),ie({width:124}),K({width:124}),V({width:124}),re({width:124})];case"orderHistory":return [B({showType:!0,width:124}),$({width:124}),G({width:124,disableEdit:!0,className:"oui-pl-0 oui-pr-0"}),z({width:124,disableEdit:!0}),pe({width:124}),te({width:124,disableEdit:!0}),J({width:124}),oe({width:124}),ie({width:124}),K({width:124}),V({width:124}),re({width:124}),Ce({width:124})]}})();function B(e){return {title:"Instrument",dataIndex:"symbol",className:"oui-h-[48px]",width:e?.width,onSort:e?.enableSort?(t,r,o)=>o==="asc"?t.symbol.localeCompare(r.symbol):r.symbol.localeCompare(t.symbol):void 0,render:(t,r)=>{typeof r.type=="string"?r.type.replace("_ORDER","").toLowerCase():r.type;let i=I(r);return jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",children:[jsxRuntime.jsx(ui.Text.formatted,{rule:"symbol",size:"xs",className:" oui-text-xs",onClick:n=>{n.stopPropagation(),n.preventDefault();},children:t}),e?.showType&&jsxRuntime.jsx(ui.Flex,{direction:"row",gap:1,children:Fe(r)?.map(n=>jsxRuntime.jsx(ui.Badge,{color:n.toLocaleLowerCase()==="position"?i?"neutural":"primary":"neutural",size:"xs",children:n}))})]})}}}function $(e){return {title:"Side",dataIndex:"side",width:e?.width,className:"oui-h-[48px]",onSort:e?.enableSort?(t,r,o)=>o==="asc"?r.side.localeCompare(t.side):t.side.localeCompare(r.side):void 0,render:(t,r)=>{let o=I(r)?"oui-text-base-contrast-20":t===types.OrderSide.BUY?"oui-text-trade-profit":"oui-text-trade-loss";return jsxRuntime.jsx("span",{className:ui.cn("oui-font-semibold",o),children:be(t)})}}}function Fr(e){return {title:"Type",dataIndex:"type",width:e?.width,className:e?.className,formatter:(t,r)=>{let o=typeof r.type=="string"?r.type.replace("_ORDER","").toLowerCase():r.type;return r.algo_order_id?`Stop ${o}`:be(t)}}}function G(e){return {title:"Filled / Quantity",dataIndex:"fill_quantity",className:e?.className,width:e?.width,onSort:e?.enableSort,render:(t,r)=>jsxRuntime.jsx(Oe,{order:r,disableEdit:e?.disableEdit})}}function kr(e){return {title:"Quantity",className:e?.className,dataIndex:"quantity",width:e?.width,onSort:e?.enableSort,render:(t,r)=>r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?"Entire position":jsxRuntime.jsx(Oe,{order:r})}}function z(e){return {title:e?.title??"Price",dataIndex:"price",className:e?.className,width:e?.width,onSort:e?.enableSort,render:(t,r)=>jsxRuntime.jsx(ot,{order:r,disableEdit:e?.disableEdit})}}function Rr(e){return {title:"Avg. price",dataIndex:"average_executed_price",className:e?.className,width:e?.width,onSort:e?.enableSort,render:(t,r)=>jsxRuntime.jsx(ui.Text,{children:utils.commifyOptional(t)})}}function te(e){return {title:"Trigger",className:e?.className,dataIndex:"trigger_price",width:e?.width,onSort:e?.enableSort,render:(t,r)=>jsxRuntime.jsx(lt,{order:r,disableEdit:e?.disableEdit})}}function ft(e){return {title:"Trigger",className:e?.className,dataIndex:"trigger_price",width:e?.width,onSort:e?.enableSort,render:(t,r)=>jsxRuntime.jsx(pt,{})}}function J(e){return {title:"Est. total",dataIndex:"executed",width:e?.width,className:e?.className,render:(t,r)=>r.type===types.OrderType.CLOSE_POSITION&&r.status!==types.OrderStatus.FILLED?"Entire position":jsxRuntime.jsx(ui.Text.numeral,{rm:utils.Decimal.ROUND_DOWN,children:r.total_executed_quantity===0||Number.isNaN(r.average_executed_price)||r.average_executed_price===null?"--":`${r.total_executed_quantity*r.average_executed_price}`})}}function K(e){return {title:"Reduce only",dataIndex:"reduce_only",width:e?.width,className:e?.className,render:t=>jsxRuntime.jsx(ui.Text,{children:t?"Yes":"No"})}}function V(e){return {title:"Hidden",dataIndex:"visible",width:e?.width,className:e?.className,render:(t,r)=>jsxRuntime.jsx(ui.Text,{children:r.visible_quantity!==0?"No":"Yes"})}}function re(e){return {title:"Order time",dataIndex:"created_time",width:e?.width,onSort:e?.enableSort,className:e?.className,render:t=>jsxRuntime.jsx(ui.Text.formatted,{rule:"date",formatString:e?.formatString||"yyyy-MM-dd HH:mm:ss",className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:t})}}function oe(e){return {title:"Fee",dataIndex:"total_fee",width:e?.width,onSort:e?.enableSort,className:e?.className}}function qr(e){return {title:"Notional",dataIndex:"notional",width:e?.width,onSort:e?.enableSort,className:e?.className,render:t=>jsxRuntime.jsx(ui.Text,{className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:t})}}function ie(e){return {title:"Status",dataIndex:"status",width:e?.width,onSort:e?.enableSort,className:e?.className,render:(t,r)=>jsxRuntime.jsx(ui.Text,{className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:ui.capitalizeFirstLetter((r?.algo_status||r.status)?.toLocaleLowerCase())})}}function pe(e){return {title:"Avg. open",dataIndex:"average_open_price",width:e?.width,onSort:e?.enableSort,className:e?.className,render:t=>jsxRuntime.jsx(ui.Text.numeral,{className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:t})}}function Ce(e){return {title:"",dataIndex:"",width:e?.width,className:e?.className,align:"right",fixed:"right",render:(t,r)=>r.status===types.OrderStatus.CANCELLED?jsxRuntime.jsx(ut,{record:r}):r.status===types.OrderStatus.NEW||r.algo_status===types.OrderStatus.NEW?jsxRuntime.jsx(Se,{order:r}):null}}function Dr(e){return {title:"",dataIndex:"",width:e?.width,className:e?.className,align:"right",fixed:"right",render:(t,r)=>jsxRuntime.jsxs(ui.Flex,{gap:3,children:[jsxRuntime.jsx(ui.Button,{size:"sm",variant:"outlined",color:"secondary",children:"Edit"}),jsxRuntime.jsx(Se,{order:r})]})}}var Te=e=>{let t=gt(e.type);return jsxRuntime.jsx(Re,{cancelOrder:e.cancelOrder,editOrder:e.updateOrder,cancelAlgoOrder:e.cancelAlgoOrder,editAlgoOrder:e.updateAlgoOrder,children:jsxRuntime.jsx(ui.Flex,{direction:"column",width:"100%",itemAlign:"start",children:jsxRuntime.jsxs(uiConnector.AuthGuardDataTable,{columns:t,loading:e.isLoading,dataSource:e.dataSource,ignoreLoadingCheck:!0,classNames:{root:"oui-items-start"},onRow:(r,o)=>({className:I(r)?"oui-text-base-contrast-20":""}),generatedRowKey:(r,o)=>`${e.type}${o}${r.order_id||r.algo_order_id}_index${o}`,renderRowContainer:(r,o,i)=>(e.type==="tp_sl"&&(i=jsxRuntime.jsx(Be,{order:r,children:i})),jsxRuntime.jsx(ze,{symbol:r.symbol,children:i})),children:[e.filterItems.length>0&&jsxRuntime.jsx(ui.Filter,{items:e.filterItems,onFilter:r=>{e.onFilter(r);}}),jsxRuntime.jsx(ui.Pagination,{...e.meta,onPageChange:e.setPage,onPageSizeChange:e.setPageSize})]})})})};var Ae=e=>{let{ordersStatus:t,type:r}=e,{page:o,pageSize:i,setPage:n,setPageSize:u,parseMeta:a}=ui.usePagination(),{orderStatus:d,ordersSide:l,dateRange:c,filterItems:m,onFilter:g}=Wr(r,{ordersStatus:t,setPage:n}),f=react.useMemo(()=>{if(r==="tp_sl")return [types.AlgoOrderRootType.POSITIONAL_TP_SL,types.AlgoOrderRootType.TP_SL]},[r]),w=react.useMemo(()=>{if(r==="pending")return [types.AlgoOrderRootType.POSITIONAL_TP_SL,types.AlgoOrderRootType.TP_SL]},[r]),[C,{isLoading:E,loadMore:O,cancelOrder:x,updateOrder:S,cancelAlgoOrder:D,updateAlgoOrder:N,meta:M}]=hooks.useOrderStream({status:d,side:l,page:o,size:i,dateRange:c,includes:f,excludes:w});return {type:r,dataSource:C,isLoading:E,loadMore:O,cancelOrder:x,updateOrder:S,cancelAlgoOrder:D,updateAlgoOrder:N,page:o,pageSize:i,setPage:n,setPageSize:u,meta:a(M),onFilter:g,filterItems:m}},Wr=(e,t)=>{let[r,o]=react.useState(t.ordersStatus),[i,n]=react.useState(void 0),[u,a]=react.useState(),d=c=>{c.name==="side"&&(n(c.value),t.setPage(1)),c.name==="status"&&(o(c.value),t.setPage(1)),c.name==="dateRange"&&(a(c.value),t.setPage(1));};return {filterItems:react.useMemo(()=>{let c={type:"select",name:"side",options:[{label:"All sides",value:void 0},{label:"Buy",value:"BUY"},{label:"Sell",value:"SELL"}],value:i},m={type:"range",name:"dateRange",value:u},g={type:"select",name:"status",options:[{label:"All status",value:void 0},{label:"Pending",value:types.OrderStatus.INCOMPLETE},{label:"Canceled",value:types.OrderStatus.CANCELLED},{label:"Rejected",value:types.OrderStatus.REJECTED}],value:r};switch(e){case"all":return [c,g,m];case"pending":return [c];case"tp_sl":return [c];case"filled":return [c];case"cancelled":return [c];case"rejected":return [c];case"orderHistory":return [c]}},[e,i,r,u]),onFilter:d,ordersSide:i,dateRange:u,orderStatus:r}};var q=e=>{let t=Ae(e);return jsxRuntime.jsx(Te,{...t})};var bt=e=>jsxRuntime.jsxs(ui.Tabs,{defaultValue:e.current||"all",variant:"contained",children:[jsxRuntime.jsx(ui.TabPanel,{value:"all",title:"All",children:jsxRuntime.jsx(q,{type:"all"})}),jsxRuntime.jsx(ui.TabPanel,{value:"pending",title:"Pending",children:jsxRuntime.jsx(q,{type:"pending",ordersStatus:types.OrderStatus.INCOMPLETE})}),jsxRuntime.jsx(ui.TabPanel,{value:"tp_sl",title:"TP/SL",children:jsxRuntime.jsx(q,{type:"tp_sl",ordersStatus:types.OrderStatus.INCOMPLETE})}),jsxRuntime.jsx(ui.TabPanel,{value:"filled",title:"Filled",children:jsxRuntime.jsx(q,{type:"filled",ordersStatus:types.OrderStatus.FILLED})}),jsxRuntime.jsx(ui.TabPanel,{value:"cancelled",title:"Cancelled",children:jsxRuntime.jsx(q,{type:"cancelled",ordersStatus:types.OrderStatus.CANCELLED})}),jsxRuntime.jsx(ui.TabPanel,{value:"rejected",title:"Rejected",children:jsxRuntime.jsx(q,{type:"rejected",ordersStatus:types.OrderStatus.REJECTED})}),jsxRuntime.jsx(ui.TabPanel,{value:"orderHistory",title:"Order history",children:jsxRuntime.jsx(q,{type:"orderHistory"})})]});var X=(a=>(a.all="all",a.pending="pending",a.tp_sl="tp_sl",a.filled="filled",a.cancelled="cancelled",a.rejected="rejected",a.orderHistory="orderHistory",a))(X||{}),Jr=e=>{let t=ye(e);return jsxRuntime.jsx(bt,{...t})};
13
+
14
+ exports.OrderList = Te;
15
+ exports.OrderListWidget = q;
16
+ exports.OrdersWidget = Jr;
17
+ exports.TabType = X;
18
+ exports.useOrderListScript = Ae;
19
+ exports.useOrdersScript = ye;
20
+ //# sourceMappingURL=out.js.map
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/orders.script.ts","../src/components/orders.ui.tsx","../src/components/orderList/orderList.ui.tsx","../src/components/orderList/useColumn.tsx","../src/utils/util.ts","../src/components/orderList/quantity.tsx","../src/components/orderList/orderListContext.tsx","../src/components/orderList/tpslOrderRowContext.tsx","../src/components/orderList/symbolProvider.tsx","../src/components/orderList/editOrder/confirmContent.tsx","../src/components/orderList/editOrder/innerInput.tsx","../src/components/orderList/price.tsx","../src/components/orderList/triggerPrice.tsx","../src/components/orderList/cancelBtn.tsx","../src/components/orderList/renew.tsx","../src/components/orderList/tpslTriggerPrice.tsx","../src/components/orderList/orderList.script.tsx","../src/components/orderList/orderList.widget.tsx","../src/components/orders.widget.tsx"],"names":["useOrdersScript","props","current","TabPanel","Tabs","OrderStatus","Flex","Pagination","Filter","AuthGuardDataTable","AlgoOrderRootType","OrderSide","OrderType","Button","capitalizeFirstLetter","cn","Text","commifyOptional","Decimal","upperCaseFirstLetter","str","parseBadgesFor","record","list","tpOrder","order","slOrder","grayCell","Badge","useCallback","useContext","useEffect","useRef","useState","Popover","toast","modal","createContext","checkNotional","useSymbolsInfo","Fragment","jsx","OrderListContext","OrderListProvider","cancelOrder","editOrder","cancelAlgoOrder","editAlgoOrder","symbolInfo","onCancelOrder","onEditOrder","position","isHidden","orderEntry","checkMinNotional","symbol","price","qty","min_notional","useMemo","unstable_serialize","useAccount","useMutation","useSWRConfig","utils","TPSLOrderRowContext","useTPSLOrderRowContext","TPSLOrderRowProvider","setPosition","doDeleteOrder","doUpdateOrder","config","state","positionKey","onUpdateOrder","params","getRelatedPosition","p","sl_trigger_price","tp_trigger_price","SymbolContext","useSymbolContext","SymbolProvider","CloseIcon","commify","jsxs","ConfirmContent","type","base","value","cancelPopover","isSubmitting","onConfirm","label","CheckIcon","Input","inputFormatter","Tooltip","InnerInput","inputRef","dp","setPrice","setEditting","error","handleKeyDown","onClick","onClose","hintInfo","input","length","e","OrderQuantity","quantity","originSetQuantity","editting","setQuantity","open","setOpen","setError","onUpdateTPSLOrder","base_dp","positionQty","closePopover","setIsSubmitting","clickHandler","notionalText","event","order_price","rest","future","result","err","componentRef","handleClickOutside","trigger","NormalState","executed","useSymbolPriceRange","Price","isAlgoOrder","isStopMarket","quote_dp","order_id","data","rangeInfo","TriggerPrice","CancelButton","isLoading","setIsLoading","res","useConfig","Renew","doCreateOrder","reset","isMutating","brokerId","onSubmit","AlgoOrderType","OrderTriggerPrice","TPSLTriggerPrice","direction","pnl","msgs","TriggerPriceItem","child","children","content","entryPrice","orderSide","orderType","useOrderColumn","_type","instrument","side","fillAndQuantity","avgOpen","tpslTriggerPrice","estTotal","fee","status","reduceOnly","hidden","cancelBtn","triggerPrice","orderTime","notional","tpslAction","avgPrice","option","r1","r2","sortOrder","badge","showGray","clsName","_","OrderList","columns","index","useOrderStream","usePagination","differenceInDays","setHours","useOrderListScript","ordersStatus","page","pageSize","setPage","setPageSize","parseMeta","orderStatus","ordersSide","dateRange","filterItems","onFilter","useFilter","includes","excludes","loadMore","updateOrder","updateAlgoOrder","meta","setOrderStatus","setOrdersSide","setDateRange","filter","sideFilter","dateRangeFilter","statusFilter","OrderListWidget","Orders","TabType","OrdersWidget"],"mappings":"AASO,IAAMA,GAAmBC,GAAiC,CAC/D,GAAM,CAAE,QAAAC,CAAQ,EAAID,EACpB,MAAO,CACL,QAAAC,CACF,CACF,ECdA,OAAoB,YAAAC,EAAU,QAAAC,OAAY,sBAE1C,OAAS,eAAAC,OAAwB,yBCDjC,OAAkB,QAAAC,GAAY,cAAAC,GAAY,UAAAC,OAAc,sBAExD,OAAS,sBAAAC,OAA0B,gCCHnC,OACE,qBAAAC,GAEA,aAAAC,GACA,eAAAN,GACA,aAAAO,OACK,yBACP,OAEE,UAAAC,GACA,yBAAAC,GACA,MAAAC,GAEA,QAAAT,GACA,QAAAU,MACK,sBACP,OAAS,mBAAAC,GAAiB,WAAAC,OAAe,yBChBzC,OAAc,eAAAb,OAAmB,yBAE1B,IAAMc,GAAwBC,GAC/BA,IAAQ,QACRA,EAAI,SAAW,EAAUA,EACzBA,EAAI,SAAW,EAAUA,EAAI,OAAO,CAAC,EAAE,YAAY,EAChDA,EAAI,OAAO,CAAC,EAAE,YAAY,EAAIA,EAAI,YAAY,EAAE,MAAM,CAAC,EAczD,SAASC,GAAeC,EAAmC,CAChE,GAAI,OAAOA,EAAO,KAAS,IACzB,OAAO,OAAOA,EAAO,MAAS,SAC1B,CAACA,EAAO,KAAK,QAAQ,SAAU,EAAE,EAAE,YAAY,CAAW,EAC1D,CAACA,EAAO,IAAc,EAG5B,GAAI,OAAOA,EAAO,UAAc,IAAa,CAC3C,IAAMC,EAAO,IAAI,MAEbD,EAAO,YAAc,oBACvBC,EAAK,KAAK,UAAU,EAGtB,IAAMC,EAAUF,EAAO,aAAa,KACjCG,GACCA,EAAM,YAAc,eAA6B,CAAC,CAACA,EAAM,aAC7D,EAEMC,EAAUJ,EAAO,aAAa,KACjCG,GACCA,EAAM,YAAc,aAA2B,CAAC,CAACA,EAAM,aAC3D,EAEA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tC,EAAA,CAAS,gBAAwB,MAAM,UACtC,SAAAsC,EAAC4L,EAAA,CACC,eACA,aAAchO,GAAY,WAC5B,EACF,EACAoC,EAACtC,EAAA,CAAS,cAAsB,MAAM,QACpC,SAAAsC,EAAC4L,EAAA,CACC,aACA,aAAchO,GAAY,WAC5B,EACF,EACAoC,EAACtC,EAAA,CAAS,eAAuB,MAAM,SACrC,SAAAsC,EAAC4L,EAAA,CACC,cACA,aAAchO,GAAY,OAC5B,EACF,EACAoC,EAACtC,EAAA,CAAS,kBAA0B,MAAM,YACxC,SAAAsC,EAAC4L,EAAA,CACC,iBACA,aAAchO,GAAY,UAC5B,EACF,EACAoC,EAACtC,EAAA,CAAS,iBAAyB,MAAM,WACvC,SAAAsC,EAAC4L,EAAA,CACC,gBACA,aAAchO,GAAY,SAC5B,EACF,EACAoC,EAACtC,EAAA,CAAS,qBAA6B,MAAM,gBAC3C,SAAAsC,EAAC4L,EAAA,CACC,oBACF,EACF,GACF,EiB/BK,cAAA5L,OAAA,oBAfF,IAAK8L,OACVA,EAAA,IAAM,MACNA,EAAA,QAAU,UACVA,EAAA,MAAQ,QACRA,EAAA,OAAS,SACTA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,aAAe,eAPLA,OAAA,IAUCC,GAEPvO,GAAU,CACd,IAAMuE,EAAQxE,GAAgBC,CAAK,EAEnC,OAAOwC,GAAC6L,GAAA,CAAQ,GAAG9J,EAAO,CAC5B","sourcesContent":["import { useState } from \"react\";\nimport {\n AlgoOrderRootType,\n OrderStatus,\n OrderSide,\n} from \"@orderly.network/types\";\nimport { useOrderStream } from \"@orderly.network/hooks\";\nimport { TabType } from \"./orders.widget\";\n\nexport const useOrdersScript = (props: { current?: TabType }) => {\n const { current } = props;\n return {\n current,\n };\n};\n\nexport type OrdersBuilderState = ReturnType<typeof useOrdersScript>;\n","import { DataTable, TabPanel, Tabs } from \"@orderly.network/ui\";\nimport { useOrderColumn } from \"./orderList/useColumn\";\nimport { OrderStatus, API } from \"@orderly.network/types\";\nimport { OrdersBuilderState } from \"./orders.script\";\nimport { TabType } from \"./orders.widget\";\nimport { OrderList, OrderListWidget } from \"./orderList\";\n\nexport const Orders = (props: OrdersBuilderState) => {\n return (\n <Tabs defaultValue={props.current || TabType.all} variant=\"contained\">\n <TabPanel value={TabType.all} title=\"All\">\n <OrderListWidget\n type={TabType.all}\n />\n </TabPanel>\n <TabPanel value={TabType.pending} title=\"Pending\">\n <OrderListWidget\n type={TabType.pending}\n ordersStatus={OrderStatus.INCOMPLETE}\n />\n </TabPanel>\n <TabPanel value={TabType.tp_sl} title=\"TP/SL\">\n <OrderListWidget\n type={TabType.tp_sl}\n ordersStatus={OrderStatus.INCOMPLETE}\n />\n </TabPanel>\n <TabPanel value={TabType.filled} title=\"Filled\">\n <OrderListWidget\n type={TabType.filled}\n ordersStatus={OrderStatus.FILLED}\n />\n </TabPanel>\n <TabPanel value={TabType.cancelled} title=\"Cancelled\">\n <OrderListWidget\n type={TabType.cancelled}\n ordersStatus={OrderStatus.CANCELLED}\n />\n </TabPanel>\n <TabPanel value={TabType.rejected} title=\"Rejected\">\n <OrderListWidget\n type={TabType.rejected}\n ordersStatus={OrderStatus.REJECTED}\n />\n </TabPanel>\n <TabPanel value={TabType.orderHistory} title=\"Order history\">\n <OrderListWidget\n type={TabType.orderHistory}\n />\n </TabPanel>\n </Tabs>\n );\n};\n// ----------------- Orders ui component end -----------------\n","import { FC } from \"react\";\nimport { Divider, Flex, Text, Pagination, Filter } from \"@orderly.network/ui\";\nimport { OrdersBuilderState } from \"./orderList.script\";\nimport { AuthGuardDataTable } from \"@orderly.network/ui-connector\";\nimport { useOrderColumn } from \"./useColumn\";\nimport { grayCell } from \"../../utils/util\";\nimport { SymbolProvider } from \"./symbolProvider\";\nimport { OrderListProvider } from \"./orderListContext\";\nimport { TabType } from \"../orders.widget\";\nimport { TPSLOrderRowProvider } from \"./tpslOrderRowContext\";\n\nexport const OrderList: FC<OrdersBuilderState> = (props) => {\n const columns = useOrderColumn(props.type);\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%\"} itemAlign={\"start\"}>\n {/* <Divider className=\"oui-w-full\" /> */}\n <AuthGuardDataTable\n columns={columns}\n loading={props.isLoading}\n dataSource={props.dataSource}\n ignoreLoadingCheck={true}\n classNames={{\n root: \"oui-items-start\",\n }}\n onRow={(record, index) => {\n return {\n className: grayCell(record) ? \"oui-text-base-contrast-20\" : \"\",\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 (props.type === TabType.tp_sl) {\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 >\n {props.filterItems.length > 0 && (\n <Filter\n items={props.filterItems}\n onFilter={(value: any) => {\n props.onFilter(value);\n }}\n />\n )}\n\n <Pagination\n {...props.meta}\n onPageChange={props.setPage}\n onPageSizeChange={props.setPageSize}\n />\n </AuthGuardDataTable>\n </Flex>\n </OrderListProvider>\n );\n};\n","import {\n AlgoOrderRootType,\n API,\n OrderSide,\n OrderStatus,\n OrderType,\n} from \"@orderly.network/types\";\nimport {\n Box,\n Button,\n capitalizeFirstLetter,\n cn,\n Column,\n Flex,\n Text,\n} from \"@orderly.network/ui\";\nimport { commifyOptional, Decimal } from \"@orderly.network/utils\";\nimport { useMemo } from \"react\";\nimport {\n grayCell,\n parseBadgesFor,\n upperCaseFirstLetter,\n} from \"../../utils/util\";\nimport { TabType } from \"../orders.widget\";\nimport { Badge } from \"@orderly.network/ui\";\nimport { OrderQuantity } from \"./quantity\";\nimport { Price } from \"./price\";\nimport { TriggerPrice } from \"./triggerPrice\";\nimport { CancelButton } from \"./cancelBtn\";\nimport { Renew } from \"./renew\";\nimport { OrderTriggerPrice } from \"./tpslTriggerPrice\";\n\nexport const useOrderColumn = (_type: TabType) => {\n const columns =\n // useMemo(\n () => {\n switch (_type) {\n case TabType.all:\n return [\n instrument({ width: 130, showType: true }),\n side({ width: 130 }),\n fillAndQuantity({\n width: 130,\n disableEdit: true,\n className: \"oui-pl-0 oui-pr-0\",\n }),\n price({ width: 130, title: \"Order price\", disableEdit: true }),\n avgOpen({ width: 130 }),\n tpslTriggerPrice({ width: 130 }),\n estTotal({ width: 130 }),\n fee({ width: 130 }),\n status({ width: 130 }),\n reduceOnly({ width: 130 }),\n hidden({ width: 130 }),\n cancelBtn({ width: 130 }),\n ];\n case TabType.pending:\n return [\n instrument({ width: 162, showType: true }),\n side({ width: 162 }),\n fillAndQuantity({ width: 162, className: \"oui-pr-0\" }),\n price({ width: 162, className: \"oui-pr-0\" }),\n triggerPrice({ width: 162, className: \"oui-pr-0\" }),\n estTotal({ width: 162 }),\n reduceOnly({ width: 162 }),\n hidden({ width: 162 }),\n orderTime({ width: 162 }),\n cancelBtn({ width: 162 }),\n ];\n case TabType.tp_sl:\n return [\n instrument({ width: 176, showType: true }),\n side({ width: 176 }),\n quantity({ width: 176 }),\n tpslTriggerPrice({ width: 176 }),\n price({ width: 176, disableEdit: true }),\n notional({ width: 176 }),\n reduceOnly({ width: 176 }),\n orderTime({ width: 176 }),\n tpslAction({ width: 176 }),\n ];\n case TabType.filled:\n return [\n instrument({ width: 124 }),\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({ width: 124, title: \"Order price\", disableEdit: true }),\n avgPrice({ 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: 124 }),\n ];\n case TabType.cancelled:\n return [\n instrument({ showType: true, 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({ 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 ];\n case TabType.rejected:\n return [\n instrument({ showType: true, 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({ 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: 124 }),\n ];\n case TabType.orderHistory:\n return [\n instrument({ showType: true, 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({ 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: 124 }),\n cancelBtn({ width: 124 }),\n ];\n }\n };\n\n // }, [_type]);\n\n return columns();\n};\n\nfunction instrument(option?: {\n showType?: boolean;\n enableSort?: boolean;\n width?: number;\n}): Column<API.Order> {\n return {\n title: \"Instrument\",\n dataIndex: \"symbol\",\n className: \"oui-h-[48px]\",\n width: option?.width,\n onSort: option?.enableSort\n ? (r1, r2, sortOrder) => {\n if (sortOrder === \"asc\") {\n return r1.symbol.localeCompare(r2.symbol);\n }\n return r2.symbol.localeCompare(r1.symbol);\n }\n : undefined,\n render: (value: string, record) => {\n const badge =\n typeof record.type === \"string\"\n ? record.type.replace(\"_ORDER\", \"\").toLowerCase()\n : record.type;\n\n const showGray = grayCell(record);\n\n return (\n <Flex direction=\"column\" itemAlign={\"start\"}>\n <Text.formatted\n rule={\"symbol\"}\n size=\"xs\"\n className=\" oui-text-xs\"\n onClick={(e) => {\n // props.onSymbolChange?.({ symbol: value } as API.Symbol);\n e.stopPropagation();\n e.preventDefault();\n }}\n >\n {value}\n </Text.formatted>\n {option?.showType && (\n <Flex direction={\"row\"} gap={1}>\n {parseBadgesFor(record)?.map((e) => (\n <Badge\n color={\n e.toLocaleLowerCase() === \"position\"\n ? showGray\n ? \"neutural\"\n : \"primary\"\n : \"neutural\"\n }\n size=\"xs\"\n >\n {e}\n </Badge>\n ))}\n </Flex>\n )}\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: \"Side\",\n dataIndex: \"side\",\n width: option?.width,\n className: \"oui-h-[48px]\",\n onSort: option?.enableSort\n ? (r1, r2, sortOrder) => {\n if (sortOrder === \"asc\") {\n return r2.side.localeCompare(r1.side);\n }\n return r1.side.localeCompare(r2.side);\n }\n : undefined,\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: \"Type\",\n dataIndex: \"type\",\n width: option?.width,\n className: option?.className,\n formatter: (value: string, record: any) => {\n const type =\n typeof record.type === \"string\"\n ? record.type.replace(\"_ORDER\", \"\").toLowerCase()\n : record.type;\n if (record.algo_order_id) {\n return `Stop ${type}`;\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.Order> {\n return {\n title: \"Filled / Quantity\",\n dataIndex: \"fill_quantity\",\n className: option?.className,\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => {\n return <OrderQuantity order={record} disableEdit={option?.disableEdit} />;\n // return value;\n },\n };\n}\n\nfunction quantity(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"Quantity\",\n className: option?.className,\n dataIndex: \"quantity\",\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => {\n if (record.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n return \"Entire position\";\n }\n return <OrderQuantity 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}): Column<API.Order> {\n return {\n title: option?.title ?? \"Price\",\n dataIndex: \"price\",\n className: option?.className,\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => {\n return <Price order={record} disableEdit={option?.disableEdit} />;\n },\n };\n}\n\nfunction avgPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n}): Column<API.Order> {\n return {\n title: \"Avg. price\",\n dataIndex: \"average_executed_price\",\n className: option?.className,\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => {\n return <Text>{commifyOptional(value)}</Text>;\n },\n };\n}\n\nfunction triggerPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n}): Column<API.Order> {\n return {\n title: \"Trigger\",\n className: option?.className,\n dataIndex: \"trigger_price\",\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => (\n <TriggerPrice order={record} disableEdit={option?.disableEdit} />\n ),\n };\n}\n\nfunction tpslTriggerPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"Trigger\",\n className: option?.className,\n dataIndex: \"trigger_price\",\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => <OrderTriggerPrice />,\n };\n}\n\nfunction estTotal(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"Est. total\",\n dataIndex: \"executed\",\n width: option?.width,\n className: option?.className,\n render: (value: string, record: any) => {\n if (\n record.type === OrderType.CLOSE_POSITION &&\n record.status !== OrderStatus.FILLED\n ) {\n return \"Entire position\";\n }\n\n return (\n <Text.numeral rm={Decimal.ROUND_DOWN}>\n {record.total_executed_quantity === 0 ||\n Number.isNaN(record.average_executed_price) ||\n record.average_executed_price === null\n ? \"--\"\n : `${\n record.total_executed_quantity * record.average_executed_price\n }`}\n </Text.numeral>\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: \"Reduce only\",\n dataIndex: \"reduce_only\",\n width: option?.width,\n className: option?.className,\n render: (value: boolean) => {\n return <Text>{value ? \"Yes\" : \"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: \"Hidden\",\n dataIndex: \"visible\",\n width: option?.width,\n className: option?.className,\n render: (value: number, record) => {\n return <Text>{record.visible_quantity !== 0 ? \"No\" : \"Yes\"}</Text>;\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: \"Order time\",\n dataIndex: \"created_time\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\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: \"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: \"Notional\",\n dataIndex: \"notional\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n render: (value: string) => (\n <Text className=\"oui-break-normal oui-whitespace-nowrap oui-font-semibold\">\n {value}\n </Text>\n ),\n };\n}\n\nfunction status(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"Status\",\n dataIndex: \"status\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n render: (value: string, record: any) => (\n <Text className=\"oui-break-normal oui-whitespace-nowrap oui-font-semibold\">\n {capitalizeFirstLetter(\n (record?.algo_status || record.status)?.toLocaleLowerCase()\n )}\n </Text>\n ),\n };\n}\n\nfunction avgOpen(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"Avg. open\",\n dataIndex: \"average_open_price\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\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 cancelBtn(option?: {\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"\",\n dataIndex: \"\",\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 tpslAction(option?: {\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"\",\n dataIndex: \"\",\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 <Button size=\"sm\" variant={\"outlined\"} color={\"secondary\"}>\n Edit\n </Button>\n <CancelButton order={record} />\n </Flex>\n );\n },\n };\n}\n","import { API, OrderStatus } from \"@orderly.network/types\";\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\nexport enum AlgoOrderType {\n TAKE_PROFIT = \"TAKE_PROFIT\",\n STOP_LOSS = \"STOP_LOSS\",\n}\n\nexport enum AlgoOrderRootType {\n TP_SL = \"TP_SL\",\n POSITIONAL_TP_SL = \"POSITIONAL_TP_SL\",\n STOP = \"STOP\",\n}\n\nexport function parseBadgesFor(record: any): undefined | string[] {\n if (typeof record.type !== \"undefined\") {\n return typeof record.type === \"string\"\n ? [record.type.replace(\"_ORDER\", \"\").toLowerCase() as string]\n : [record.type as string];\n }\n\n if (typeof record.algo_type !== \"undefined\") {\n const list = new Array<string>();\n\n if (record.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n list.push(\"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(tpOrder && slOrder ? \"TP/SL\" : tpOrder ? \"TP\" : \"SL\");\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","import {\n FC,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { API, OrderSide } from \"@orderly.network/types\";\nimport { AlgoOrderRootType } from \"@orderly.network/types\";\nimport { cn, Flex, Popover, toast, Text } from \"@orderly.network/ui\";\nimport { OrderListContext } from \"./orderListContext\";\nimport { useTPSLOrderRowContext } from \"./tpslOrderRowContext\";\nimport { useSymbolContext } from \"./symbolProvider\";\nimport { grayCell } from \"../../utils/util\";\nimport { ConfirmContent, EditType } from \"./editOrder/confirmContent\";\nimport { InnerInput } from \"./editOrder/innerInput\";\n\nexport const OrderQuantity = (props: {\n order: API.OrderExt | API.AlgoOrder;\n disableEdit?: boolean;\n}) => {\n const { order } = props;\n\n const [quantity, originSetQuantity] = useState<string>(\n order.quantity.toString()\n );\n\n const [editting, setEditting] = useState(false);\n\n useEffect(() => {\n setQuantity(order.quantity.toString());\n }, [props.order.quantity]);\n\n const [open, setOpen] = useState(false);\n const [error, setError] = useState<string>();\n\n const { editOrder, editAlgoOrder, checkMinNotional } =\n useContext(OrderListContext);\n const { onUpdateOrder: onUpdateTPSLOrder, position } =\n useTPSLOrderRowContext();\n\n const { base_dp, base } = useSymbolContext();\n\n const setQuantity = (qty: string) => {\n originSetQuantity(qty);\n const positionQty = Math.abs(position?.position_qty || 0);\n if (position && Number(qty) > positionQty) {\n setError(\n `Quantity should be less than position quantity : ${positionQty}`\n );\n } else {\n setError(undefined);\n }\n };\n\n const closePopover = () => {\n setOpen(false);\n setEditting(false);\n };\n const cancelPopover = () => {\n setOpen(false);\n setQuantity(order.quantity.toString());\n setEditting(false);\n };\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const clickHandler = () => {\n console.log(\"xxxxx click handler\", checkMinNotional, quantity);\n\n if (!!error) {\n return;\n }\n\n if (Number(quantity) === Number(order.quantity)) {\n setEditting(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, quantity);\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: quantity,\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 !== undefined) {\n params = { ...params, order_tag: order.order_tag };\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) => {\n closePopover();\n setQuantity(quantity.toString());\n // setTimeout(() => inputRef.current?.blur(), 300);\n },\n (err) => {\n toast.error(err.message);\n setQuantity(order.quantity.toString());\n cancelPopover();\n }\n )\n .finally(() => setIsSubmitting(false));\n }, [quantity]);\n\n const componentRef = useRef<HTMLDivElement | null>(null);\n\n const handleClickOutside = (event: any) => {\n if (\n componentRef.current &&\n !componentRef.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]);\n\n const trigger = () => {\n if (!editting || props.disableEdit) {\n return (\n <NormalState\n order={order}\n quantity={quantity}\n setEditing={setEditting}\n disableEdit={props.disableEdit}\n />\n );\n }\n\n return (\n <InnerInput\n inputRef={inputRef}\n dp={base_dp}\n value={quantity}\n setPrice={setQuantity}\n setEditting={setEditting}\n handleKeyDown={handleKeyDown}\n onClick={onClick}\n onClose={cancelPopover}\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={quantity}\n cancelPopover={cancelPopover}\n isSubmitting={isSubmitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div ref={componentRef}>{trigger()}</div>\n </Popover>\n );\n};\n\nconst NormalState: FC<{\n order: API.AlgoOrder | API.OrderExt;\n quantity: string;\n setEditing: any;\n partial?: boolean;\n disableEdit?: boolean;\n}> = (props) => {\n const { order, quantity } = 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-max-w-[110px] oui-relative\",\n\n order.side === OrderSide.BUY && \"oui-text-trade-profit\",\n order.side === OrderSide.SELL && \"oui-text-trade-loss\",\n grayCell(order) && \"oui-text-base-conrast-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-min-w-[70px] oui-h-[28px]\",\n !props.disableEdit && \"oui-bg-base-7 oui-px-2\"\n )}\n >\n <Text size=\"2xs\">{quantity}</Text>\n </Flex>\n </Flex>\n );\n};\n","import { modal } from \"@orderly.network/ui\";\nimport { API, OrderEntity } from \"@orderly.network/types\";\nimport { FC, PropsWithChildren, createContext, useCallback } from \"react\";\n\nimport { checkNotional, useSymbolsInfo } from \"@orderly.network/hooks\";\n\nexport interface OrderListContextState {\n onCancelOrder: (order: API.Order | API.AlgoOrder) => Promise<any>;\n onEditOrder: (\n order: API.Order | API.AlgoOrder,\n position?: API.Position\n ) => 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 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 {\n cancelOrder,\n editOrder,\n cancelAlgoOrder,\n editAlgoOrder,\n // cancelTPSLOrder,\n } = props;\n const symbolInfo = useSymbolsInfo();\n const onCancelOrder = useCallback(\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\n const onEditOrder = useCallback(\n async (order: API.Order | API.AlgoOrder, position?: API.Position) => {\n // @ts-ignore\n let 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 const orderEntry = await modal.sheet({\n title: \"Edit Order\",\n contentClassName: \"orderly-edit-order-sheet-content\",\n content: (\n // <OrderEditFormSheet\n // order={order}\n // position={position}\n // editOrder={(value: OrderEntity) => {\n // /// check order has order_tag, if exits add order_tag to request body\n // if (\n // typeof order.order_tag !== undefined &&\n // order.reduce_only !== true\n // ) {\n // value = { ...value, order_tag: order.order_tag };\n // }\n // if (order.algo_order_id !== undefined) {\n // return editAlgoOrder(order.algo_order_id.toString(), {\n // ...value,\n // });\n // }\n // return editOrder((order as any).order_id.toString(), {\n // ...value,\n // ...(isHidden ? { visible_quantity: 0 } : {}),\n // });\n // }}\n // />\n <>Content</>\n ),\n });\n },\n []\n );\n\n const checkMinNotional = useCallback(\n (symbol: string, price?: string | number, qty?: string | number) => {\n const { min_notional } = symbolInfo[symbol]();\n return checkNotional(price, qty, min_notional);\n },\n [symbolInfo]\n );\n\n return (\n <OrderListContext.Provider\n value={{\n onCancelOrder,\n onEditOrder,\n editOrder,\n editAlgoOrder,\n checkMinNotional,\n }}\n >\n {props.children}\n </OrderListContext.Provider>\n );\n};\n","import {\n createContext,\n FC,\n PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { API } from \"@orderly.network/types\";\nimport {\n unstable_serialize,\n useAccount,\n useMutation,\n useSWRConfig,\n utils,\n} from \"@orderly.network/hooks\";\n\nexport type TPSLOrderRowContextState = {\n order: API.AlgoOrderExt;\n tp_trigger_price?: number;\n sl_trigger_price?: 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(\n {} as TPSLOrderRowContextState\n);\n\nexport const useTPSLOrderRowContext = () => {\n return useContext(TPSLOrderRowContext);\n};\n\nexport const TPSLOrderRowProvider: FC<\n PropsWithChildren<{\n order: API.AlgoOrderExt;\n }>\n> = (props) => {\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 = 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 = async (order: API.AlgoOrderExt, params: any) => {\n console.log(\"onUpdateOrder\", order, position);\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 const getRelatedPosition = (\n symbol: string\n ): API.PositionTPSLExt | undefined => {\n const positions = config.cache.get(positionKey);\n\n return positions?.data.rows.find(\n (p: API.PositionTPSLExt) => p.symbol === symbol\n );\n };\n\n const { sl_trigger_price, tp_trigger_price } = useMemo(() => {\n if (\n !(\"algo_type\" in props.order) ||\n !Array.isArray(props.order.child_orders)\n ) {\n return {};\n }\n return utils.findTPSLFromOrder(props.order);\n }, [props.order]);\n\n useEffect(() => {\n if (\"algo_type\" in props.order) {\n const position = getRelatedPosition(props.order.symbol);\n if (position) {\n setPosition(position);\n }\n }\n }, [props.order.symbol]);\n\n return (\n <TPSLOrderRowContext.Provider\n value={{\n order: props.order,\n sl_trigger_price,\n tp_trigger_price,\n onCancelOrder,\n onUpdateOrder,\n getRelatedPosition,\n position,\n }}\n >\n {props.children}\n </TPSLOrderRowContext.Provider>\n );\n};\n","import React, {\n FC,\n PropsWithChildren,\n createContext,\n useMemo,\n useContext,\n} from \"react\";\nimport { useSymbolsInfo } from \"@orderly.network/hooks\";\n\ninterface SymbolContextState {\n base_dp: number;\n quote_dp: number;\n base_tick: number;\n base: string;\n quote: string;\n symbol: string;\n}\n\nexport const SymbolContext = createContext({} as SymbolContextState);\n\nexport const useSymbolContext = () => {\n return useContext(SymbolContext);\n};\n\ninterface FormatterProviderProps {\n symbol: string;\n}\n\nexport const SymbolProvider: FC<PropsWithChildren<FormatterProviderProps>> = (\n props\n) => {\n const symbolInfo = useSymbolsInfo()[props.symbol];\n\n return (\n <SymbolContext.Provider\n value={{\n base_dp: symbolInfo(\"base_dp\"),\n quote_dp: symbolInfo(\"quote_dp\"),\n base_tick: symbolInfo(\"base_tick\"),\n base: symbolInfo(\"base\"),\n quote: symbolInfo(\"quote\"),\n symbol: props.symbol,\n }}\n >\n {props.children}\n </SymbolContext.Provider>\n );\n};\n","import { Button, CloseIcon } from \"@orderly.network/ui\";\nimport { commify } from \"@orderly.network/utils\";\nimport { FC, useMemo } from \"react\";\n\nexport enum EditType {\n quantity,\n price,\n triggerPrice,\n}\n\nexport const ConfirmContent: FC<{\n type: EditType;\n base: string;\n value: string;\n cancelPopover: () => void;\n isSubmitting: boolean;\n onConfirm: (e: any) => void;\n}> = (props) => {\n const { type, base, value, cancelPopover, isSubmitting, onConfirm } = props;\n\n const label = useMemo(() => {\n switch (type) {\n case EditType.quantity:\n return `You agree changing the quantity of ${base}-PERP order to${\" \"}`;\n case EditType.price:\n return `You agree changing the price of ${base}-PERP order to${\" \"}`;\n case EditType.triggerPrice:\n return `You agree changing the trigger price of ${base}-PERP order to${\" \"}`;\n }\n }, [type]);\n\n return (\n <div className=\"oui-pt-5 oui-relative\">\n <div className=\"oui-text-base-contrast-54 oui-text-2xs desktop:oui-text-sm\">\n {label}\n <span className=\"oui-text-warning\">{commify(value)}</span>.\n </div>\n <div className=\"oui-grid oui-grid-cols-2 oui-gap-2 oui-mt-5\">\n <Button\n color=\"secondary\"\n onClick={cancelPopover}\n disabled={isSubmitting}\n >\n Cancel\n </Button>\n <Button loading={isSubmitting} onClick={onConfirm}>\n Confirm\n </Button>\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={18} />\n </button>\n </div>\n );\n};\n","import { CheckIcon, CloseIcon, Input, inputFormatter, Tooltip } from \"@orderly.network/ui\";\nimport { FC, useEffect } from \"react\";\n\nexport const InnerInput: FC<{\n inputRef: any;\n value: string;\n setPrice: any;\n setEditting: any;\n error?: string;\n handleKeyDown: (e: any) => void;\n onClick: (e: any) => void;\n onClose: (e: any) => void;\n dp: number;\n hintInfo?: string;\n }> = (props) => {\n const {\n inputRef,\n dp,\n value,\n setPrice,\n setEditting,\n error,\n handleKeyDown,\n onClick,\n onClose,\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 setEditting(true);\n }, []);\n return (\n <Tooltip content={hintInfo} open={(hintInfo?.length || 0) > 0}>\n <Input\n ref={inputRef}\n type=\"text\"\n size=\"sm\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(dp),\n ]}\n value={value}\n onValueChange={(e) => setPrice(e)}\n helpText={error}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n onKeyDown={handleKeyDown}\n autoFocus\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 };","import { API } from \"@orderly.network/types\";\nimport { commifyOptional } from \"@orderly.network/utils\";\nimport { FC, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useSymbolPriceRange } from \"@orderly.network/hooks\";\nimport { cn, Flex, Popover, toast, Text } from \"@orderly.network/ui\";\nimport { OrderListContext } from \"./orderListContext\";\nimport { useSymbolContext } from \"./symbolProvider\";\nimport { grayCell } from \"../../utils/util\";\nimport { ConfirmContent, EditType } from \"./editOrder/confirmContent\";\nimport { InnerInput } from \"./editOrder/innerInput\";\n\nexport const Price = (props: {\n order: API.OrderExt;\n disableEdit?: boolean;\n}) => {\n const { order } = props;\n\n const [price, setPrice] = useState<string>(\n order.price?.toString() ?? \"Market\"\n );\n\n const [open, setOpen] = useState(false);\n const [editting, setEditting] = useState(false);\n\n const isAlgoOrder = order?.algo_order_id !== undefined;\n // console.log(\"price node\", order);\n\n const isStopMarket = order?.type === \"MARKET\" && isAlgoOrder;\n\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const { editOrder, editAlgoOrder, checkMinNotional } =\n useContext(OrderListContext);\n\n const { base, quote_dp } = useSymbolContext();\n const closePopover = () => {\n setOpen(false);\n setEditting(false);\n };\n const cancelPopover = () => {\n setOpen(false);\n setPrice(order.price?.toString() ?? \"Market\");\n setEditting(false);\n };\n\n const onClick = (event: any) => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (price === `${order.price}`) {\n setEditting(false);\n return;\n }\n\n if (order.reduce_only !== true) {\n const notionalText = checkMinNotional(\n order.symbol,\n price,\n order.quantity\n );\n if (notionalText) {\n toast.error(notionalText);\n setIsSubmitting(false);\n cancelPopover();\n return;\n }\n }\n\n setOpen(true);\n };\n\n const handleKeyDown = (event: any) => {\n if (event.key === \"Enter\") {\n onClick(event);\n }\n };\n\n const onConfirm = () => {\n setIsSubmitting(true);\n\n let order_id = order.order_id;\n let data: any = {\n order_price: price,\n order_quantity: order.quantity,\n symbol: order.symbol,\n order_type: order.type,\n side: order.side,\n // reduce_only: Boolean(order.reduce_only),\n };\n if (typeof order.reduce_only !== \"undefined\") {\n data.reduce_only = order.reduce_only;\n }\n\n if (order.order_tag !== undefined) {\n data = { ...data, order_tag: order.order_tag };\n }\n\n if (isAlgoOrder) {\n order_id = order.algo_order_id as number;\n data = {\n ...data,\n order_id,\n price: price,\n algo_order_id: order_id,\n };\n }\n\n if (order?.visible_quantity === 0) {\n data[\"visible_quantity\"] = 0;\n }\n\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(\n (result) => {\n closePopover();\n setPrice(price);\n // setTimeout(() => inputRef.current?.blur(), 300);\n },\n (err) => {\n toast.error(err.message);\n\n setPrice(order.price!.toString());\n cancelPopover();\n }\n )\n .finally(() => setIsSubmitting(false));\n };\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const rangeInfo = useSymbolPriceRange(\n order.symbol,\n // @ts-ignore\n order.side,\n isAlgoOrder ? order.trigger_price : undefined\n );\n\n const hintInfo = useMemo(() => {\n if (!rangeInfo) return \"\";\n if (isStopMarket) return \"\";\n if (!editting) return \"\";\n\n if (Number(price) > rangeInfo.max) {\n return `Price can not be greater than ${rangeInfo.max} USDC.`;\n }\n if (Number(price) < rangeInfo.min) {\n return `Price can not be less than ${rangeInfo.min} USDC.`;\n }\n return \"\";\n }, [isStopMarket, editting, rangeInfo, price]);\n\n useEffect(() => {\n {\n if (!!props.order.price) {\n setPrice(`${props.order.price}`);\n }\n }\n }, [props.order.price]);\n\n const componentRef = useRef<HTMLDivElement | null>(null);\n\n const handleClickOutside = (event: any) => {\n if (\n componentRef.current &&\n !componentRef.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]);\n\n const isAlgoMarketOrder = order.algo_order_id && order.type == \"MARKET\";\n\n \n if (isAlgoMarketOrder || price === \"Market\") {\n return <span>Market</span>;\n }\n\n const trigger = () => {\n if (!editting || props.disableEdit) {\n return (\n <NormalState\n order={order}\n price={price}\n setEditing={setEditting}\n disableEdit={props.disableEdit}\n />\n );\n }\n\n return (\n <InnerInput\n inputRef={inputRef}\n dp={quote_dp}\n value={price}\n setPrice={setPrice}\n setEditting={setEditting}\n handleKeyDown={handleKeyDown}\n onClick={onClick}\n onClose={cancelPopover}\n hintInfo={hintInfo}\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={price}\n cancelPopover={cancelPopover}\n isSubmitting={isSubmitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div ref={componentRef}>{trigger()}</div>\n </Popover>\n );\n};\n\nconst NormalState: FC<{\n order: any;\n price: string;\n setEditing: any;\n disableEdit?: boolean;\n}> = (props) => {\n const { order, price } = props;\n\n return (\n <div\n className={cn(\n \"oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold\",\n grayCell(order) && \"oui-text-base-conrast-20\"\n )}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.setEditing(true);\n }}\n >\n <Flex\n r=\"base\"\n className={cn(\n \"oui-min-w-[70px] oui-h-[28px]\",\n !props.disableEdit && \"oui-bg-base-7 oui-px-2\"\n )}\n >\n <Text size=\"2xs\">{commifyOptional(price)}</Text>\n </Flex>\n </div>\n );\n};\n","import { API } from \"@orderly.network/types\";\nimport { FC, useContext, useEffect, useRef, useState } from \"react\";\nimport { cn, Flex, Popover, toast, Text } from \"@orderly.network/ui\";\nimport { OrderListContext } from \"./orderListContext\";\nimport { useSymbolContext } from \"./symbolProvider\";\nimport { grayCell } from \"../../utils/util\";\nimport { ConfirmContent, EditType } from \"./editOrder/confirmContent\";\nimport { InnerInput } from \"./editOrder/innerInput\";\n\nexport const TriggerPrice = (props: {\n order: API.OrderExt;\n disableEdit?: boolean;\n}) => {\n const { order } = props;\n\n const [price, setPrice] = useState<string>(\"\");\n\n useEffect(() => {\n setPrice(order.trigger_price?.toString() ?? \"0\");\n }, [order.trigger_price]);\n\n const isAlgoOrder = order?.algo_order_id !== undefined;\n const [open, setOpen] = useState(false);\n const [editting, setEditting] = useState(false);\n\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const { editAlgoOrder, checkMinNotional } = useContext(OrderListContext);\n\n const { base, quote_dp } = useSymbolContext();\n const closePopover = () => {\n setOpen(false);\n setEditting(false);\n };\n const cancelPopover = () => {\n setPrice(order.trigger_price?.toString() ?? \"0\");\n setOpen(false);\n setEditting(false);\n };\n\n const componentRef = useRef<HTMLDivElement | null>(null);\n\n const handleClickOutside = (event: any) => {\n if (\n componentRef.current &&\n !componentRef.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]);\n\n const onClick = (event: any) => {\n event?.stopPropagation();\n event?.preventDefault();\n\n setEditting(false);\n\n if (Number(price) === Number(order.trigger_price)) {\n return;\n }\n\n if (order.price && order.reduce_only !== true) {\n const notionalText = checkMinNotional(\n order.symbol,\n order.price,\n order.quantity\n );\n if (notionalText) {\n toast.error(notionalText);\n setIsSubmitting(false);\n cancelPopover();\n return;\n }\n }\n\n setOpen(true);\n };\n\n const handleKeyDown = (event: any) => {\n if (event.key === \"Enter\") {\n onClick(event);\n }\n };\n\n const onConfirm = () => {\n setIsSubmitting(true);\n\n let data: any = {\n // price: price,\n quantity: order.quantity,\n trigger_price: price,\n symbol: order.symbol,\n // order_type: order.type,\n // side: order.side,\n // reduce_only: Boolean(order.reduce_only),\n algo_order_id: order.algo_order_id,\n };\n\n if (order.order_tag !== undefined) {\n data = { ...data, order_tag: order.order_tag };\n }\n\n editAlgoOrder(`${order.algo_order_id}`, data)\n .then(\n (result) => {\n closePopover();\n setPrice(price);\n // setTimeout(() => inputRef.current?.blur(), 300);\n },\n (err) => {\n toast.error(err.message);\n\n setPrice(order.trigger_price?.toString() ?? \"--\");\n cancelPopover();\n }\n )\n .finally(() => setIsSubmitting(false));\n };\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n if (!isAlgoOrder) {\n return <Text>{`--`}</Text>;\n }\n const trigger = () => {\n if (!editting || props.disableEdit) {\n return (\n <NormalState\n order={order}\n price={price}\n setEditing={setEditting}\n disableEdit={props.disableEdit}\n />\n );\n }\n\n return (\n <InnerInput\n inputRef={inputRef}\n dp={quote_dp}\n value={price}\n setPrice={setPrice}\n setEditting={setEditting}\n handleKeyDown={handleKeyDown}\n onClick={onClick}\n onClose={cancelPopover}\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={price}\n cancelPopover={cancelPopover}\n isSubmitting={isSubmitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div ref={componentRef}>{trigger()}</div>\n </Popover>\n );\n};\n\nconst NormalState: FC<{\n order: any;\n price: string;\n setEditing: any;\n disableEdit?: boolean;\n}> = (props) => {\n const { order, price } = props;\n\n return (\n <div\n className={cn(\n \"oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold\",\n grayCell(order) && \"oui-text-base-conrast-20\"\n )}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.setEditing(true);\n }}\n >\n <Flex\n r=\"base\"\n className={cn(\n \"oui-min-w-[70px] oui-h-[28px]\",\n !props.disableEdit && \"oui-bg-base-7 oui-px-2\"\n )}\n >\n <Text size=\"2xs\">{price}</Text>\n </Flex>\n </div>\n );\n};\n","import { API } from \"@orderly.network/types\";\nimport { Button, toast } from \"@orderly.network/ui\";\nimport { FC, useContext, useState } from \"react\";\nimport { OrderListContext } from \"./orderListContext\";\n\nexport const CancelButton: FC<{\n order: API.Order;\n}> = (props) => {\n const { order } = props;\n\n const { onCancelOrder } = useContext(OrderListContext);\n const [isLoading, setIsLoading] = useState(false);\n\n return (\n <Button\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) => res,\n (error) => {\n toast.error(error.message);\n }\n )\n .finally(() => {\n setIsLoading(false);\n });\n }}\n loading = {isLoading}\n >\n Cancel\n </Button>\n );\n};\n","import { FC, useCallback, useContext, useMemo, useState } from \"react\";\n\nimport { useConfig, useMutation } from \"@orderly.network/hooks\";\nimport { OrderEntity } from \"@orderly.network/types\";\nimport { Button } from \"@orderly.network/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 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 // visible_quantity: record.visible,\n side: record.side,\n // reduce_only: record.reduce_only,\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 doCreateOrder(data);\n }, []);\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 Renew\n </Button>\n );\n};\n","import { FC, useMemo } from \"react\";\nimport { useSymbolsInfo, utils } from \"@orderly.network/hooks\";\nimport { API, AlgoOrderType } from \"@orderly.network/types\";\nimport { OrderSide } from \"@orderly.network/types\";\nimport { cn, Text, Tooltip } from \"@orderly.network/ui\"\nimport { useTPSLOrderRowContext } from \"./tpslOrderRowContext\";\n\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\n\nconst 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\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\"\n )}\n key={\"tp\"}\n rule=\"price\"\n precision={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 TP&nbsp;-&nbsp;\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 \"\n )}\n rule={\"price\"}\n precision={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 SL&nbsp;-&nbsp;\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]);\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 <Tooltip content={pnl}>{content}</Tooltip>;\n }\n\n return content;\n};\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 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\n return (\n <div className=\"oui-flex oui-items-center\">\n <span className=\"oui-text-base-contrast-54 oui-mr-1\">{`${type} PnL:`}</span>\n <Text.numeral\n rule=\"price\"\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 surfix={\n <span className=\"oui-text-base-contrast-36 oui-ml-1\">\n USDC\n </span>\n }\n >{`${Math.abs(pnl)}`}</Text.numeral>\n </div>\n );\n};","import { useMemo, useState } from \"react\";\nimport {\n AlgoOrderRootType,\n OrderStatus,\n OrderSide,\n} from \"@orderly.network/types\";\nimport { useOrderStream } from \"@orderly.network/hooks\";\nimport { TabType } from \"../orders.widget\";\nimport { DataFilterItems, usePagination } from \"@orderly.network/ui\";\nimport { differenceInDays, setHours } from \"date-fns\";\n\nexport const useOrderListScript = (props: {\n type: TabType;\n ordersStatus?: OrderStatus;\n}) => {\n const { ordersStatus, type } = props;\n\n const { page, pageSize, setPage, setPageSize, parseMeta } = usePagination();\n const { orderStatus, ordersSide, dateRange, filterItems, onFilter } =\n useFilter(type, {\n ordersStatus,\n setPage,\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\n const [\n data,\n {\n isLoading,\n loadMore,\n cancelOrder,\n updateOrder,\n cancelAlgoOrder,\n updateAlgoOrder,\n meta,\n },\n ] = useOrderStream({\n status: orderStatus,\n side: ordersSide,\n page: page,\n size: pageSize,\n dateRange,\n includes,\n excludes,\n });\n\n return {\n type,\n dataSource: data,\n isLoading,\n loadMore,\n cancelOrder,\n updateOrder,\n cancelAlgoOrder,\n updateAlgoOrder,\n\n // pagination\n page,\n pageSize,\n setPage,\n setPageSize,\n meta: parseMeta(meta),\n\n // filter\n onFilter,\n filterItems,\n };\n};\n\nconst useFilter = (\n type: TabType,\n option: {\n setPage: (page: number) => void;\n ordersStatus?: OrderStatus;\n }\n) => {\n const [orderStatus, setOrderStatus] = useState<OrderStatus | undefined>(\n option.ordersStatus\n );\n const [ordersSide, setOrdersSide] = useState<OrderSide | undefined>(\n undefined\n );\n const [dateRange, setDateRange] = useState<{\n from?: Date;\n to?: Date;\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(filter.value);\n option.setPage(1);\n }\n };\n\n const filterItems = useMemo((): any[] => {\n const sideFilter = {\n type: \"select\",\n name: \"side\",\n options: [\n {\n label: \"All sides\",\n value: undefined,\n },\n {\n label: \"Buy\",\n value: \"BUY\",\n },\n {\n label: \"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: \"All status\",\n value: undefined,\n },\n {\n label: \"Pending\",\n value: OrderStatus.INCOMPLETE,\n },\n {\n label: \"Canceled\",\n value: OrderStatus.CANCELLED,\n },\n {\n label: \"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];\n }\n }, [type, ordersSide, orderStatus, dateRange]);\n\n return {\n filterItems,\n onFilter,\n ordersSide,\n dateRange,\n orderStatus,\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","import { OrderStatus } from \"@orderly.network/types\";\nimport { useOrderListScript } from \"./orderList.script\";\nimport { OrderList } from \"./orderList.ui\";\nimport { TabType } from \"../orders.widget\";\n\nexport const OrderListWidget = (props: {\n type: TabType;\n ordersStatus?: OrderStatus;\n}) => {\n const state = useOrderListScript(props);\n return (\n <OrderList {...state}/>\n );\n};\n","import { FC } from \"react\";\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 const OrdersWidget: FC<{\n current?: TabType;\n}> = (props) => {\n const state = useOrdersScript(props);\n\n return <Orders {...state} />;\n};\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { Flex, Filter, Pagination, usePagination, modal, Text, Badge, cn, capitalizeFirstLetter, Button, Tabs, TabPanel, toast, Popover, Tooltip, CloseIcon, Input, inputFormatter, CheckIcon } from '@orderly.network/ui';
2
+ import { AlgoOrderRootType, OrderStatus, OrderSide, OrderType, AlgoOrderType } from '@orderly.network/types';
3
+ import { AuthGuardDataTable } from '@orderly.network/ui-connector';
4
+ import { commifyOptional, Decimal, commify } from '@orderly.network/utils';
5
+ import { createContext, useMemo, useState, useCallback, useEffect, useContext, useRef } from 'react';
6
+ import { useOrderStream, useSymbolsInfo, checkNotional, useMutation, useSWRConfig, useAccount, unstable_serialize, utils, useSymbolPriceRange, useConfig } from '@orderly.network/hooks';
7
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
+ import 'date-fns';
9
+
10
+ var ye=e=>{let{current:t}=e;return {current:t}};var be=e=>e===void 0||e.length===0?e:e.length===1?e.charAt(0).toUpperCase():e.charAt(0).toUpperCase()+e.toLowerCase().slice(1);function Fe(e){if(typeof e.type<"u")return typeof e.type=="string"?[e.type.replace("_ORDER","").toLowerCase()]:[e.type];if(typeof e.algo_type<"u"){let t=new Array;e.algo_type==="POSITIONAL_TP_SL"&&t.push("Position");let r=e.child_orders.find(i=>i.algo_type==="TAKE_PROFIT"&&!!i.trigger_price),o=e.child_orders.find(i=>i.algo_type==="STOP_LOSS"&&!!i.trigger_price);return (r||o)&&t.push(r&&o?"TP/SL":r?"TP":"SL"),t}}function I(e){return e.status===OrderStatus.CANCELLED||e.algo_status===OrderStatus.CANCELLED}var A=createContext({}),Re=e=>{let{cancelOrder:t,editOrder:r,cancelAlgoOrder:o,editAlgoOrder:i}=e,n=useSymbolsInfo(),u=useCallback(async l=>l.algo_order_id!==void 0?"root_algo_order_id"in l&&l.root_algo_order_id!==l.algo_order_id?o(l.root_algo_order_id,l.symbol):o(l.algo_order_id,l.symbol).then(()=>{}):t(l.order_id,l.symbol).then(()=>{}),[]),a=useCallback(async(l,c)=>{l.visible_quantity!==void 0?l.visible_quantity===0:l.visible!==void 0?l.visible===0:!1;await modal.sheet({title:"Edit Order",contentClassName:"orderly-edit-order-sheet-content",content:jsx(Fragment,{children:"Content"})});},[]),d=useCallback((l,c,m)=>{let{min_notional:g}=n[l]();return checkNotional(c,m,g)},[n]);return jsx(A.Provider,{value:{onCancelOrder:u,onEditOrder:a,editOrder:r,editAlgoOrder:i,checkMinNotional:d},children:e.children})};var Me=createContext({}),le=()=>useContext(Me),Be=e=>{let[t,r]=useState(),[o]=useMutation("/v1/algo/order","DELETE"),[i]=useMutation("/v1/algo/order","PUT"),n=useSWRConfig(),{state:u}=useAccount(),a=useMemo(()=>unstable_serialize(()=>["/v1/positions",u.accountId]),[u.accountId]),d=async f=>o(null,{order_id:f.algo_order_id,symbol:f.symbol}),l=async(f,w)=>i({order_id:f.algo_order_id,child_orders:f.child_orders.map(C=>({order_id:C.algo_order_id,quantity:w.order_quantity}))}),c=f=>n.cache.get(a)?.data.rows.find(C=>C.symbol===f),{sl_trigger_price:m,tp_trigger_price:g}=useMemo(()=>!("algo_type"in e.order)||!Array.isArray(e.order.child_orders)?{}:utils.findTPSLFromOrder(e.order),[e.order]);return useEffect(()=>{if("algo_type"in e.order){let f=c(e.order.symbol);f&&r(f);}},[e.order.symbol]),jsx(Me.Provider,{value:{order:e.order,sl_trigger_price:m,tp_trigger_price:g,onCancelOrder:d,onUpdateOrder:l,getRelatedPosition:c,position:t},children:e.children})};var $e=createContext({}),W=()=>useContext($e),ze=e=>{let t=useSymbolsInfo()[e.symbol];return jsx($e.Provider,{value:{base_dp:t("base_dp"),quote_dp:t("quote_dp"),base_tick:t("base_tick"),base:t("base"),quote:t("quote"),symbol:e.symbol},children:e.children})};var Q=e=>{let{type:t,base:r,value:o,cancelPopover:i,isSubmitting:n,onConfirm:u}=e,a=useMemo(()=>{switch(t){case 0:return `You agree changing the quantity of ${r}-PERP order to `;case 1:return `You agree changing the price of ${r}-PERP order to `;case 2:return `You agree changing the trigger price of ${r}-PERP order to `}},[t]);return jsxs("div",{className:"oui-pt-5 oui-relative",children:[jsxs("div",{className:"oui-text-base-contrast-54 oui-text-2xs desktop:oui-text-sm",children:[a,jsx("span",{className:"oui-text-warning",children:commify(o)}),"."]}),jsxs("div",{className:"oui-grid oui-grid-cols-2 oui-gap-2 oui-mt-5",children:[jsx(Button,{color:"secondary",onClick:i,disabled:n,children:"Cancel"}),jsx(Button,{loading:n,onClick:u,children:"Confirm"})]}),jsx("button",{className:"oui-absolute oui-right-0 oui-top-0 oui-text-base-contrast-54",onClick:i,children:jsx(CloseIcon,{size:18})})]})};var Y=e=>{let{inputRef:t,dp:r,value:o,setPrice:i,setEditting:n,error:u,handleKeyDown:a,onClick:d,onClose:l,hintInfo:c}=e;return useEffect(()=>{let m=t.current;if(m){let g=m.value.length;m.setSelectionRange(g,g);}n(!0);},[]),jsx(Tooltip,{content:c,open:(c?.length||0)>0,children:jsx(Input,{ref:t,type:"text",size:"sm",formatters:[inputFormatter.numberFormatter,inputFormatter.dpFormatter(r)],value:o,onValueChange:m=>i(m),helpText:u,onClick:m=>{m.stopPropagation(),m.preventDefault();},onKeyDown:a,autoFocus:!0,classNames:{root:"oui-bg-base-700 oui-px-2 oui-py-1 oui-rounded",input:"oui-pr-2"},suffix:jsx("button",{onClick:d,children:jsx(CheckIcon,{size:18,color:"white",opacity:1,className:"oui-cursor-pointer oui-opacity-50 hover:oui-opacity-100"})})})})};var Oe=e=>{let{order:t}=e,[r,o]=useState(t.quantity.toString()),[i,n]=useState(!1);useEffect(()=>{O(t.quantity.toString());},[e.order.quantity]);let[u,a]=useState(!1),[d,l]=useState(),{editOrder:c,editAlgoOrder:m,checkMinNotional:g}=useContext(A),{onUpdateOrder:f,position:w}=le(),{base_dp:C,base:E}=W(),O=s=>{o(s);let P=Math.abs(w?.position_qty||0);w&&Number(s)>P?l(`Quantity should be less than position quantity : ${P}`):l(void 0);},x=()=>{a(!1),n(!1);},S=()=>{a(!1),O(t.quantity.toString()),n(!1);},[D,N]=useState(!1),M=useRef(null),T=()=>{if(d)return;if(Number(r)===Number(t.quantity)){n(!1);return}let s=t.algo_order_id!==void 0?t.trigger_price:t.price;if(s!==null&&t.reduce_only!==!0){let P=g(t.symbol,s,r);if(P){toast.error(P),N(!1),S();return}}a(!0);},b=s=>{s?.stopPropagation(),s?.preventDefault(),T();},v=s=>{s.key==="Enter"&&(s?.stopPropagation(),s?.preventDefault(),T());},ae=useCallback(()=>{N(!0);let s={symbol:t.symbol,order_type:t.type,side:t.side,order_price:t.price,order_quantity:r,algo_order_id:t.algo_order_id};if(typeof s.algo_order_id<"u"&&s.order_type==="MARKET"){let{order_price:U,...Pt}=s;s=Pt;}typeof t.reduce_only<"u"&&(s.reduce_only=t.reduce_only),t.order_tag!==void 0&&(s={...s,order_tag:t.order_tag}),t?.visible_quantity===0&&(s.visible_quantity=0),t?.tag!==void 0&&(s.order_tag=t.tag);let P;"algo_type"in t&&t.algo_type===AlgoOrderRootType.TP_SL?P=f(t,s):t.algo_order_id!==void 0?P=m(t.algo_order_id.toString(),s):P=c(t.order_id.toString(),s),P.then(U=>{x(),O(r.toString());},U=>{toast.error(U.message),O(t.quantity.toString()),S();}).finally(()=>N(!1));},[r]),se=useRef(null),de=s=>{se.current&&!se.current.contains(s.target)&&!u&&S();};useEffect(()=>(document.addEventListener("mousedown",de),()=>{document.removeEventListener("mousedown",de);}),[u]);let _=()=>!i||e.disableEdit?jsx(Gt,{order:t,quantity:r,setEditing:n,disableEdit:e.disableEdit}):jsx(Y,{inputRef:M,dp:C,value:r,setPrice:O,setEditting:n,handleKeyDown:v,onClick:b,onClose:S});return jsx(Popover,{open:u,onOpenChange:a,content:jsx(Q,{type:0,base:E,value:r,cancelPopover:S,isSubmitting:D,onConfirm:ae}),children:jsx("div",{ref:se,children:_()})})},Gt=e=>{let{order:t,quantity:r}=e,o=t.total_executed_quantity;return jsxs(Flex,{direction:"row",justify:"start",gap:1,className:cn("oui-max-w-[110px] oui-relative",t.side===OrderSide.BUY&&"oui-text-trade-profit",t.side===OrderSide.SELL&&"oui-text-trade-loss",I(t)&&"oui-text-base-conrast-20"),onClick:i=>{i.stopPropagation(),i.preventDefault(),e.setEditing(!0);},children:["algo_type"in t&&t.algo_type===AlgoOrderRootType.TP_SL?null:jsxs(Fragment,{children:[jsx("span",{children:o}),jsx("span",{children:"/"})]}),jsx(Flex,{r:"base",className:cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2"),children:jsx(Text,{size:"2xs",children:r})})]})};var ot=e=>{let{order:t}=e,[r,o]=useState(t.price?.toString()??"Market"),[i,n]=useState(!1),[u,a]=useState(!1),d=t?.algo_order_id!==void 0,l=t?.type==="MARKET"&&d,[c,m]=useState(!1),{editOrder:g,editAlgoOrder:f,checkMinNotional:w}=useContext(A),{base:C,quote_dp:E}=W(),O=()=>{n(!1),a(!1);},x=()=>{n(!1),o(t.price?.toString()??"Market"),a(!1);},S=_=>{if(_?.stopPropagation(),_?.preventDefault(),r===`${t.price}`){a(!1);return}if(t.reduce_only!==!0){let s=w(t.symbol,r,t.quantity);if(s){toast.error(s),m(!1),x();return}}n(!0);},D=_=>{_.key==="Enter"&&S(_);},N=()=>{m(!0);let _=t.order_id,s={order_price:r,order_quantity:t.quantity,symbol:t.symbol,order_type:t.type,side:t.side};typeof t.reduce_only<"u"&&(s.reduce_only=t.reduce_only),t.order_tag!==void 0&&(s={...s,order_tag:t.order_tag}),d&&(_=t.algo_order_id,s={...s,order_id:_,price:r,algo_order_id:_}),t?.visible_quantity===0&&(s.visible_quantity=0),t.tag!==void 0&&(s.order_tag=t.tag);let P;t.algo_order_id!==void 0?P=f(t.algo_order_id.toString(),s):P=g(t.order_id.toString(),s),P.then(U=>{O(),o(r);},U=>{toast.error(U.message),o(t.price.toString()),x();}).finally(()=>m(!1));},M=useRef(null),T=useSymbolPriceRange(t.symbol,t.side,d?t.trigger_price:void 0),b=useMemo(()=>!T||l||!u?"":Number(r)>T.max?`Price can not be greater than ${T.max} USDC.`:Number(r)<T.min?`Price can not be less than ${T.min} USDC.`:"",[l,u,T,r]);useEffect(()=>{e.order.price&&o(`${e.order.price}`);},[e.order.price]);let v=useRef(null),ae=_=>{v.current&&!v.current.contains(_.target)&&!i&&x();};if(useEffect(()=>(document.addEventListener("mousedown",ae),()=>{document.removeEventListener("mousedown",ae);}),[i]),t.algo_order_id&&t.type=="MARKET"||r==="Market")return jsx("span",{children:"Market"});let de=()=>!u||e.disableEdit?jsx(or,{order:t,price:r,setEditing:a,disableEdit:e.disableEdit}):jsx(Y,{inputRef:M,dp:E,value:r,setPrice:o,setEditting:a,handleKeyDown:D,onClick:S,onClose:x,hintInfo:b});return jsx(Popover,{open:i,onOpenChange:n,content:jsx(Q,{type:1,base:C,value:r,cancelPopover:x,isSubmitting:c,onConfirm:N}),children:jsx("div",{ref:v,children:de()})})},or=e=>{let{order:t,price:r}=e;return jsx("div",{className:cn("oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold",I(t)&&"oui-text-base-conrast-20"),onClick:o=>{o.stopPropagation(),o.preventDefault(),e.setEditing(!0);},children:jsx(Flex,{r:"base",className:cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2"),children:jsx(Text,{size:"2xs",children:commifyOptional(r)})})})};var lt=e=>{let{order:t}=e,[r,o]=useState("");useEffect(()=>{o(t.trigger_price?.toString()??"0");},[t.trigger_price]);let i=t?.algo_order_id!==void 0,[n,u]=useState(!1),[a,d]=useState(!1),[l,c]=useState(!1),{editAlgoOrder:m,checkMinNotional:g}=useContext(A),{base:f,quote_dp:w}=W(),C=()=>{u(!1),d(!1);},E=()=>{o(t.trigger_price?.toString()??"0"),u(!1),d(!1);},O=useRef(null),x=b=>{O.current&&!O.current.contains(b.target)&&!n&&E();};useEffect(()=>(document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x);}),[n]);let S=b=>{if(b?.stopPropagation(),b?.preventDefault(),d(!1),Number(r)!==Number(t.trigger_price)){if(t.price&&t.reduce_only!==!0){let v=g(t.symbol,t.price,t.quantity);if(v){toast.error(v),c(!1),E();return}}u(!0);}},D=b=>{b.key==="Enter"&&S(b);},N=()=>{c(!0);let b={quantity:t.quantity,trigger_price:r,symbol:t.symbol,algo_order_id:t.algo_order_id};t.order_tag!==void 0&&(b={...b,order_tag:t.order_tag}),m(`${t.algo_order_id}`,b).then(v=>{C(),o(r);},v=>{toast.error(v.message),o(t.trigger_price?.toString()??"--"),E();}).finally(()=>c(!1));},M=useRef(null);if(!i)return jsx(Text,{children:"--"});let T=()=>!a||e.disableEdit?jsx(sr,{order:t,price:r,setEditing:d,disableEdit:e.disableEdit}):jsx(Y,{inputRef:M,dp:w,value:r,setPrice:o,setEditting:d,handleKeyDown:D,onClick:S,onClose:E});return jsx(Popover,{open:n,onOpenChange:u,content:jsx(Q,{type:2,base:f,value:r,cancelPopover:E,isSubmitting:l,onConfirm:N}),children:jsx("div",{ref:O,children:T()})})},sr=e=>{let{order:t,price:r}=e;return jsx("div",{className:cn("oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold",I(t)&&"oui-text-base-conrast-20"),onClick:o=>{o.stopPropagation(),o.preventDefault(),e.setEditing(!0);},children:jsx(Flex,{r:"base",className:cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2"),children:jsx(Text,{size:"2xs",children:r})})})};var Se=e=>{let{order:t}=e,{onCancelOrder:r}=useContext(A),[o,i]=useState(!1);return jsx(Button,{size:"sm",variant:"outlined",color:"secondary",onClick:n=>{r&&(n.preventDefault(),n.stopPropagation(),i(!0),r(t).then(u=>u,u=>{toast.error(u.message);}).finally(()=>{i(!1);}));},loading:o,children:"Cancel"})};var ut=e=>{let{record:t}=e,[r,o]=useState(!1),[i,{data:n,error:u,reset:a,isMutating:d}]=useMutation("/v1/order"),l=useConfig("brokerId"),c=useCallback(()=>{o(!1);let m={symbol:t.symbol,order_type:t.type,order_price:t.price,order_quantity:t.quantity,order_amount:t.amount,side:t.side,broker_id:l};Number(t.visible_quantity)<Number(t.quantity)&&(m.visible_quantity=0),typeof t.reduce_only<"u"&&(m.reduce_only=t.reduce_only),i(m);},[]);return jsx(Button,{size:"sm",variant:"outlined",color:"secondary",loading:d,disabled:d,onClick:m=>{d||(m.preventDefault(),m.stopPropagation(),c());},children:"Renew"})};var pt=()=>{let{sl_trigger_price:e,tp_trigger_price:t,order:r,position:o}=le();return jsx(_r,{stopLossPrice:e,takeProfitPrice:t,direction:"column",order:r,position:o,tooltip:!0})},_r=e=>{let{direction:t="row",order:r,position:o}=e,i=useSymbolsInfo(),n=useMemo(()=>{let d=[];if(!e.tooltip||!r||!o)return;let l=r.quantity;return l===0&&r.child_orders[0].type==="CLOSE_POSITION"&&(l=o.position_qty),e.takeProfitPrice&&d.push(jsx(mt,{qty:l,price:e.takeProfitPrice,entryPrice:o.average_open_price,orderSide:r.side,orderType:AlgoOrderType.TAKE_PROFIT,symbolInfo:i[r.symbol]()},"tp")),e.stopLossPrice&&d.push(jsx(mt,{qty:l,price:e.stopLossPrice,entryPrice:o.average_open_price,orderSide:r.side,orderType:AlgoOrderType.STOP_LOSS,symbolInfo:i[r.symbol]()},"sl")),jsx("div",{children:d})},[e.takeProfitPrice,e.stopLossPrice,o?.average_open_price,r?.side,r?.quantity,r?.algo_type]),u=useMemo(()=>{let d=[];return r?.symbol?(e.takeProfitPrice&&d.push(jsx(Text.numeral,{className:cn("oui-text-trade-profit oui-gap-0 oui-decoration-white/20"),rule:"price",precision:i[r.symbol]("quote_dp",2),children:e.takeProfitPrice,prefix:!e.stopLossPrice||t==="column"?jsx("span",{className:"oui-text-base-contrast-54",children:"TP\xA0-\xA0"}):""},"tp")),e.stopLossPrice&&d.push(jsx(Text.numeral,{className:cn("oui-text-trade-loss oui-gap-0 oui-decoration-white/20 "),rule:"price",precision:i[r.symbol]("quote_dp",2),children:e.stopLossPrice,prefix:!e.takeProfitPrice||t==="column"?jsx("span",{className:"oui-text-base-contrast-54",children:"SL\xA0-\xA0"}):""},"sl")),d.length===0?jsx("span",{children:"-"}):(d.length===2&&t==="row"&&d.splice(1,0,jsx("span",{children:"/"},"split")),d)):jsx("span",{children:"-"})},[e.takeProfitPrice,e.stopLossPrice,r?.symbol]),a=jsx("div",{className:cn("oui-inline-flex oui-text-base-contrast-36",e.direction==="column"?"oui-flex-col":"oui-flex-row oui-gap-1",e.className),children:u});return e.tooltip?jsx(Tooltip,{content:n,children:a}):a},mt=e=>{let{qty:t,price:r,entryPrice:o,orderSide:i,orderType:n,symbolInfo:u}=e,a=utils.priceToPnl({qty:t,price:r,entryPrice:o,orderSide:i,orderType:n},{symbol:u}),d=n===AlgoOrderType.TAKE_PROFIT?"TP":"SL";return jsxs("div",{className:"oui-flex oui-items-center",children:[jsx("span",{className:"oui-text-base-contrast-54 oui-mr-1",children:`${d} PnL:`}),jsx(Text.numeral,{rule:"price",className:a===0?"oui-text-base-contrast-36":a>0?"oui-text-trade-profit oui-gap-0":"oui-text-trade-loss oui-gap-0",prefix:jsx("span",{children:a===0?"":a>0?"+":"-"}),surfix:jsx("span",{className:"oui-text-base-contrast-36 oui-ml-1",children:"USDC"}),children:`${Math.abs(a)}`})]})};var gt=e=>(()=>{switch(e){case"all":return [B({width:130,showType:!0}),$({width:130}),G({width:130,disableEdit:!0,className:"oui-pl-0 oui-pr-0"}),z({width:130,title:"Order price",disableEdit:!0}),pe({width:130}),ft({width:130}),J({width:130}),oe({width:130}),ie({width:130}),K({width:130}),V({width:130}),Ce({width:130})];case"pending":return [B({width:162,showType:!0}),$({width:162}),G({width:162,className:"oui-pr-0"}),z({width:162,className:"oui-pr-0"}),te({width:162,className:"oui-pr-0"}),J({width:162}),K({width:162}),V({width:162}),re({width:162}),Ce({width:162})];case"tp_sl":return [B({width:176,showType:!0}),$({width:176}),kr({width:176}),ft({width:176}),z({width:176,disableEdit:!0}),qr({width:176}),K({width:176}),re({width:176}),Dr({width:176})];case"filled":return [B({width:124}),Fr({width:124}),$({width:124}),G({width:124,disableEdit:!0,className:"oui-pl-0 oui-pr-0"}),z({width:124,title:"Order price",disableEdit:!0}),Rr({width:124}),te({width:124,disableEdit:!0}),J({width:124}),oe({width:124}),ie({width:124}),K({width:124}),V({width:124}),re({width:124})];case"cancelled":return [B({showType:!0,width:124}),$({width:124}),G({width:124,disableEdit:!0,className:"oui-pl-0 oui-pr-0"}),z({width:124,disableEdit:!0}),pe({width:124}),te({width:124,disableEdit:!0}),J({width:124}),oe({width:124}),ie({width:124}),K({width:124}),V({width:124})];case"rejected":return [B({showType:!0,width:124}),$({width:124}),G({width:124,disableEdit:!0,className:"oui-pl-0 oui-pr-0"}),z({width:124,disableEdit:!0}),pe({width:124}),te({width:124,disableEdit:!0}),J({width:124}),oe({width:124}),ie({width:124}),K({width:124}),V({width:124}),re({width:124})];case"orderHistory":return [B({showType:!0,width:124}),$({width:124}),G({width:124,disableEdit:!0,className:"oui-pl-0 oui-pr-0"}),z({width:124,disableEdit:!0}),pe({width:124}),te({width:124,disableEdit:!0}),J({width:124}),oe({width:124}),ie({width:124}),K({width:124}),V({width:124}),re({width:124}),Ce({width:124})]}})();function B(e){return {title:"Instrument",dataIndex:"symbol",className:"oui-h-[48px]",width:e?.width,onSort:e?.enableSort?(t,r,o)=>o==="asc"?t.symbol.localeCompare(r.symbol):r.symbol.localeCompare(t.symbol):void 0,render:(t,r)=>{typeof r.type=="string"?r.type.replace("_ORDER","").toLowerCase():r.type;let i=I(r);return jsxs(Flex,{direction:"column",itemAlign:"start",children:[jsx(Text.formatted,{rule:"symbol",size:"xs",className:" oui-text-xs",onClick:n=>{n.stopPropagation(),n.preventDefault();},children:t}),e?.showType&&jsx(Flex,{direction:"row",gap:1,children:Fe(r)?.map(n=>jsx(Badge,{color:n.toLocaleLowerCase()==="position"?i?"neutural":"primary":"neutural",size:"xs",children:n}))})]})}}}function $(e){return {title:"Side",dataIndex:"side",width:e?.width,className:"oui-h-[48px]",onSort:e?.enableSort?(t,r,o)=>o==="asc"?r.side.localeCompare(t.side):t.side.localeCompare(r.side):void 0,render:(t,r)=>{let o=I(r)?"oui-text-base-contrast-20":t===OrderSide.BUY?"oui-text-trade-profit":"oui-text-trade-loss";return jsx("span",{className:cn("oui-font-semibold",o),children:be(t)})}}}function Fr(e){return {title:"Type",dataIndex:"type",width:e?.width,className:e?.className,formatter:(t,r)=>{let o=typeof r.type=="string"?r.type.replace("_ORDER","").toLowerCase():r.type;return r.algo_order_id?`Stop ${o}`:be(t)}}}function G(e){return {title:"Filled / Quantity",dataIndex:"fill_quantity",className:e?.className,width:e?.width,onSort:e?.enableSort,render:(t,r)=>jsx(Oe,{order:r,disableEdit:e?.disableEdit})}}function kr(e){return {title:"Quantity",className:e?.className,dataIndex:"quantity",width:e?.width,onSort:e?.enableSort,render:(t,r)=>r.algo_type===AlgoOrderRootType.POSITIONAL_TP_SL?"Entire position":jsx(Oe,{order:r})}}function z(e){return {title:e?.title??"Price",dataIndex:"price",className:e?.className,width:e?.width,onSort:e?.enableSort,render:(t,r)=>jsx(ot,{order:r,disableEdit:e?.disableEdit})}}function Rr(e){return {title:"Avg. price",dataIndex:"average_executed_price",className:e?.className,width:e?.width,onSort:e?.enableSort,render:(t,r)=>jsx(Text,{children:commifyOptional(t)})}}function te(e){return {title:"Trigger",className:e?.className,dataIndex:"trigger_price",width:e?.width,onSort:e?.enableSort,render:(t,r)=>jsx(lt,{order:r,disableEdit:e?.disableEdit})}}function ft(e){return {title:"Trigger",className:e?.className,dataIndex:"trigger_price",width:e?.width,onSort:e?.enableSort,render:(t,r)=>jsx(pt,{})}}function J(e){return {title:"Est. total",dataIndex:"executed",width:e?.width,className:e?.className,render:(t,r)=>r.type===OrderType.CLOSE_POSITION&&r.status!==OrderStatus.FILLED?"Entire position":jsx(Text.numeral,{rm:Decimal.ROUND_DOWN,children:r.total_executed_quantity===0||Number.isNaN(r.average_executed_price)||r.average_executed_price===null?"--":`${r.total_executed_quantity*r.average_executed_price}`})}}function K(e){return {title:"Reduce only",dataIndex:"reduce_only",width:e?.width,className:e?.className,render:t=>jsx(Text,{children:t?"Yes":"No"})}}function V(e){return {title:"Hidden",dataIndex:"visible",width:e?.width,className:e?.className,render:(t,r)=>jsx(Text,{children:r.visible_quantity!==0?"No":"Yes"})}}function re(e){return {title:"Order time",dataIndex:"created_time",width:e?.width,onSort:e?.enableSort,className:e?.className,render:t=>jsx(Text.formatted,{rule:"date",formatString:e?.formatString||"yyyy-MM-dd HH:mm:ss",className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:t})}}function oe(e){return {title:"Fee",dataIndex:"total_fee",width:e?.width,onSort:e?.enableSort,className:e?.className}}function qr(e){return {title:"Notional",dataIndex:"notional",width:e?.width,onSort:e?.enableSort,className:e?.className,render:t=>jsx(Text,{className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:t})}}function ie(e){return {title:"Status",dataIndex:"status",width:e?.width,onSort:e?.enableSort,className:e?.className,render:(t,r)=>jsx(Text,{className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:capitalizeFirstLetter((r?.algo_status||r.status)?.toLocaleLowerCase())})}}function pe(e){return {title:"Avg. open",dataIndex:"average_open_price",width:e?.width,onSort:e?.enableSort,className:e?.className,render:t=>jsx(Text.numeral,{className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:t})}}function Ce(e){return {title:"",dataIndex:"",width:e?.width,className:e?.className,align:"right",fixed:"right",render:(t,r)=>r.status===OrderStatus.CANCELLED?jsx(ut,{record:r}):r.status===OrderStatus.NEW||r.algo_status===OrderStatus.NEW?jsx(Se,{order:r}):null}}function Dr(e){return {title:"",dataIndex:"",width:e?.width,className:e?.className,align:"right",fixed:"right",render:(t,r)=>jsxs(Flex,{gap:3,children:[jsx(Button,{size:"sm",variant:"outlined",color:"secondary",children:"Edit"}),jsx(Se,{order:r})]})}}var Te=e=>{let t=gt(e.type);return jsx(Re,{cancelOrder:e.cancelOrder,editOrder:e.updateOrder,cancelAlgoOrder:e.cancelAlgoOrder,editAlgoOrder:e.updateAlgoOrder,children:jsx(Flex,{direction:"column",width:"100%",itemAlign:"start",children:jsxs(AuthGuardDataTable,{columns:t,loading:e.isLoading,dataSource:e.dataSource,ignoreLoadingCheck:!0,classNames:{root:"oui-items-start"},onRow:(r,o)=>({className:I(r)?"oui-text-base-contrast-20":""}),generatedRowKey:(r,o)=>`${e.type}${o}${r.order_id||r.algo_order_id}_index${o}`,renderRowContainer:(r,o,i)=>(e.type==="tp_sl"&&(i=jsx(Be,{order:r,children:i})),jsx(ze,{symbol:r.symbol,children:i})),children:[e.filterItems.length>0&&jsx(Filter,{items:e.filterItems,onFilter:r=>{e.onFilter(r);}}),jsx(Pagination,{...e.meta,onPageChange:e.setPage,onPageSizeChange:e.setPageSize})]})})})};var Ae=e=>{let{ordersStatus:t,type:r}=e,{page:o,pageSize:i,setPage:n,setPageSize:u,parseMeta:a}=usePagination(),{orderStatus:d,ordersSide:l,dateRange:c,filterItems:m,onFilter:g}=Wr(r,{ordersStatus:t,setPage:n}),f=useMemo(()=>{if(r==="tp_sl")return [AlgoOrderRootType.POSITIONAL_TP_SL,AlgoOrderRootType.TP_SL]},[r]),w=useMemo(()=>{if(r==="pending")return [AlgoOrderRootType.POSITIONAL_TP_SL,AlgoOrderRootType.TP_SL]},[r]),[C,{isLoading:E,loadMore:O,cancelOrder:x,updateOrder:S,cancelAlgoOrder:D,updateAlgoOrder:N,meta:M}]=useOrderStream({status:d,side:l,page:o,size:i,dateRange:c,includes:f,excludes:w});return {type:r,dataSource:C,isLoading:E,loadMore:O,cancelOrder:x,updateOrder:S,cancelAlgoOrder:D,updateAlgoOrder:N,page:o,pageSize:i,setPage:n,setPageSize:u,meta:a(M),onFilter:g,filterItems:m}},Wr=(e,t)=>{let[r,o]=useState(t.ordersStatus),[i,n]=useState(void 0),[u,a]=useState(),d=c=>{c.name==="side"&&(n(c.value),t.setPage(1)),c.name==="status"&&(o(c.value),t.setPage(1)),c.name==="dateRange"&&(a(c.value),t.setPage(1));};return {filterItems:useMemo(()=>{let c={type:"select",name:"side",options:[{label:"All sides",value:void 0},{label:"Buy",value:"BUY"},{label:"Sell",value:"SELL"}],value:i},m={type:"range",name:"dateRange",value:u},g={type:"select",name:"status",options:[{label:"All status",value:void 0},{label:"Pending",value:OrderStatus.INCOMPLETE},{label:"Canceled",value:OrderStatus.CANCELLED},{label:"Rejected",value:OrderStatus.REJECTED}],value:r};switch(e){case"all":return [c,g,m];case"pending":return [c];case"tp_sl":return [c];case"filled":return [c];case"cancelled":return [c];case"rejected":return [c];case"orderHistory":return [c]}},[e,i,r,u]),onFilter:d,ordersSide:i,dateRange:u,orderStatus:r}};var q=e=>{let t=Ae(e);return jsx(Te,{...t})};var bt=e=>jsxs(Tabs,{defaultValue:e.current||"all",variant:"contained",children:[jsx(TabPanel,{value:"all",title:"All",children:jsx(q,{type:"all"})}),jsx(TabPanel,{value:"pending",title:"Pending",children:jsx(q,{type:"pending",ordersStatus:OrderStatus.INCOMPLETE})}),jsx(TabPanel,{value:"tp_sl",title:"TP/SL",children:jsx(q,{type:"tp_sl",ordersStatus:OrderStatus.INCOMPLETE})}),jsx(TabPanel,{value:"filled",title:"Filled",children:jsx(q,{type:"filled",ordersStatus:OrderStatus.FILLED})}),jsx(TabPanel,{value:"cancelled",title:"Cancelled",children:jsx(q,{type:"cancelled",ordersStatus:OrderStatus.CANCELLED})}),jsx(TabPanel,{value:"rejected",title:"Rejected",children:jsx(q,{type:"rejected",ordersStatus:OrderStatus.REJECTED})}),jsx(TabPanel,{value:"orderHistory",title:"Order history",children:jsx(q,{type:"orderHistory"})})]});var X=(a=>(a.all="all",a.pending="pending",a.tp_sl="tp_sl",a.filled="filled",a.cancelled="cancelled",a.rejected="rejected",a.orderHistory="orderHistory",a))(X||{}),Jr=e=>{let t=ye(e);return jsx(bt,{...t})};
11
+
12
+ export { Te as OrderList, q as OrderListWidget, Jr as OrdersWidget, X as TabType, Ae as useOrderListScript, ye as useOrdersScript };
13
+ //# sourceMappingURL=out.js.map
14
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/orders.script.ts","../src/components/orders.ui.tsx","../src/components/orderList/orderList.ui.tsx","../src/components/orderList/useColumn.tsx","../src/utils/util.ts","../src/components/orderList/quantity.tsx","../src/components/orderList/orderListContext.tsx","../src/components/orderList/tpslOrderRowContext.tsx","../src/components/orderList/symbolProvider.tsx","../src/components/orderList/editOrder/confirmContent.tsx","../src/components/orderList/editOrder/innerInput.tsx","../src/components/orderList/price.tsx","../src/components/orderList/triggerPrice.tsx","../src/components/orderList/cancelBtn.tsx","../src/components/orderList/renew.tsx","../src/components/orderList/tpslTriggerPrice.tsx","../src/components/orderList/orderList.script.tsx","../src/components/orderList/orderList.widget.tsx","../src/components/orders.widget.tsx"],"names":["useOrdersScript","props","current","TabPanel","Tabs","OrderStatus","Flex","Pagination","Filter","AuthGuardDataTable","AlgoOrderRootType","OrderSide","OrderType","Button","capitalizeFirstLetter","cn","Text","commifyOptional","Decimal","upperCaseFirstLetter","str","parseBadgesFor","record","list","tpOrder","order","slOrder","grayCell","Badge","useCallback","useContext","useEffect","useRef","useState","Popover","toast","modal","createContext","checkNotional","useSymbolsInfo","Fragment","jsx","OrderListContext","OrderListProvider","cancelOrder","editOrder","cancelAlgoOrder","editAlgoOrder","symbolInfo","onCancelOrder","onEditOrder","position","isHidden","orderEntry","checkMinNotional","symbol","price","qty","min_notional","useMemo","unstable_serialize","useAccount","useMutation","useSWRConfig","utils","TPSLOrderRowContext","useTPSLOrderRowContext","TPSLOrderRowProvider","setPosition","doDeleteOrder","doUpdateOrder","config","state","positionKey","onUpdateOrder","params","getRelatedPosition","p","sl_trigger_price","tp_trigger_price","SymbolContext","useSymbolContext","SymbolProvider","CloseIcon","commify","jsxs","ConfirmContent","type","base","value","cancelPopover","isSubmitting","onConfirm","label","CheckIcon","Input","inputFormatter","Tooltip","InnerInput","inputRef","dp","setPrice","setEditting","error","handleKeyDown","onClick","onClose","hintInfo","input","length","e","OrderQuantity","quantity","originSetQuantity","editting","setQuantity","open","setOpen","setError","onUpdateTPSLOrder","base_dp","positionQty","closePopover","setIsSubmitting","clickHandler","notionalText","event","order_price","rest","future","result","err","componentRef","handleClickOutside","trigger","NormalState","executed","useSymbolPriceRange","Price","isAlgoOrder","isStopMarket","quote_dp","order_id","data","rangeInfo","TriggerPrice","CancelButton","isLoading","setIsLoading","res","useConfig","Renew","doCreateOrder","reset","isMutating","brokerId","onSubmit","AlgoOrderType","OrderTriggerPrice","TPSLTriggerPrice","direction","pnl","msgs","TriggerPriceItem","child","children","content","entryPrice","orderSide","orderType","useOrderColumn","_type","instrument","side","fillAndQuantity","avgOpen","tpslTriggerPrice","estTotal","fee","status","reduceOnly","hidden","cancelBtn","triggerPrice","orderTime","notional","tpslAction","avgPrice","option","r1","r2","sortOrder","badge","showGray","clsName","_","OrderList","columns","index","useOrderStream","usePagination","differenceInDays","setHours","useOrderListScript","ordersStatus","page","pageSize","setPage","setPageSize","parseMeta","orderStatus","ordersSide","dateRange","filterItems","onFilter","useFilter","includes","excludes","loadMore","updateOrder","updateAlgoOrder","meta","setOrderStatus","setOrdersSide","setDateRange","filter","sideFilter","dateRangeFilter","statusFilter","OrderListWidget","Orders","TabType","OrdersWidget"],"mappings":"AASO,IAAMA,GAAmBC,GAAiC,CAC/D,GAAM,CAAE,QAAAC,CAAQ,EAAID,EACpB,MAAO,CACL,QAAAC,CACF,CACF,ECdA,OAAoB,YAAAC,EAAU,QAAAC,OAAY,sBAE1C,OAAS,eAAAC,OAAwB,yBCDjC,OAAkB,QAAAC,GAAY,cAAAC,GAAY,UAAAC,OAAc,sBAExD,OAAS,sBAAAC,OAA0B,gCCHnC,OACE,qBAAAC,GAEA,aAAAC,GACA,eAAAN,GACA,aAAAO,OACK,yBACP,OAEE,UAAAC,GACA,yBAAAC,GACA,MAAAC,GAEA,QAAAT,GACA,QAAAU,MACK,sBACP,OAAS,mBAAAC,GAAiB,WAAAC,OAAe,yBChBzC,OAAc,eAAAb,OAAmB,yBAE1B,IAAMc,GAAwBC,GAC/BA,IAAQ,QACRA,EAAI,SAAW,EAAUA,EACzBA,EAAI,SAAW,EAAUA,EAAI,OAA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EAAA,QAAU,UACVA,EAAA,MAAQ,QACRA,EAAA,OAAS,SACTA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,aAAe,eAPLA,OAAA,IAUCC,GAEPvO,GAAU,CACd,IAAMuE,EAAQxE,GAAgBC,CAAK,EAEnC,OAAOwC,GAAC6L,GAAA,CAAQ,GAAG9J,EAAO,CAC5B","sourcesContent":["import { useState } from \"react\";\nimport {\n AlgoOrderRootType,\n OrderStatus,\n OrderSide,\n} from \"@orderly.network/types\";\nimport { useOrderStream } from \"@orderly.network/hooks\";\nimport { TabType } from \"./orders.widget\";\n\nexport const useOrdersScript = (props: { current?: TabType }) => {\n const { current } = props;\n return {\n current,\n };\n};\n\nexport type OrdersBuilderState = ReturnType<typeof useOrdersScript>;\n","import { DataTable, TabPanel, Tabs } from \"@orderly.network/ui\";\nimport { useOrderColumn } from \"./orderList/useColumn\";\nimport { OrderStatus, API } from \"@orderly.network/types\";\nimport { OrdersBuilderState } from \"./orders.script\";\nimport { TabType } from \"./orders.widget\";\nimport { OrderList, OrderListWidget } from \"./orderList\";\n\nexport const Orders = (props: OrdersBuilderState) => {\n return (\n <Tabs defaultValue={props.current || TabType.all} variant=\"contained\">\n <TabPanel value={TabType.all} title=\"All\">\n <OrderListWidget\n type={TabType.all}\n />\n </TabPanel>\n <TabPanel value={TabType.pending} title=\"Pending\">\n <OrderListWidget\n type={TabType.pending}\n ordersStatus={OrderStatus.INCOMPLETE}\n />\n </TabPanel>\n <TabPanel value={TabType.tp_sl} title=\"TP/SL\">\n <OrderListWidget\n type={TabType.tp_sl}\n ordersStatus={OrderStatus.INCOMPLETE}\n />\n </TabPanel>\n <TabPanel value={TabType.filled} title=\"Filled\">\n <OrderListWidget\n type={TabType.filled}\n ordersStatus={OrderStatus.FILLED}\n />\n </TabPanel>\n <TabPanel value={TabType.cancelled} title=\"Cancelled\">\n <OrderListWidget\n type={TabType.cancelled}\n ordersStatus={OrderStatus.CANCELLED}\n />\n </TabPanel>\n <TabPanel value={TabType.rejected} title=\"Rejected\">\n <OrderListWidget\n type={TabType.rejected}\n ordersStatus={OrderStatus.REJECTED}\n />\n </TabPanel>\n <TabPanel value={TabType.orderHistory} title=\"Order history\">\n <OrderListWidget\n type={TabType.orderHistory}\n />\n </TabPanel>\n </Tabs>\n );\n};\n// ----------------- Orders ui component end -----------------\n","import { FC } from \"react\";\nimport { Divider, Flex, Text, Pagination, Filter } from \"@orderly.network/ui\";\nimport { OrdersBuilderState } from \"./orderList.script\";\nimport { AuthGuardDataTable } from \"@orderly.network/ui-connector\";\nimport { useOrderColumn } from \"./useColumn\";\nimport { grayCell } from \"../../utils/util\";\nimport { SymbolProvider } from \"./symbolProvider\";\nimport { OrderListProvider } from \"./orderListContext\";\nimport { TabType } from \"../orders.widget\";\nimport { TPSLOrderRowProvider } from \"./tpslOrderRowContext\";\n\nexport const OrderList: FC<OrdersBuilderState> = (props) => {\n const columns = useOrderColumn(props.type);\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%\"} itemAlign={\"start\"}>\n {/* <Divider className=\"oui-w-full\" /> */}\n <AuthGuardDataTable\n columns={columns}\n loading={props.isLoading}\n dataSource={props.dataSource}\n ignoreLoadingCheck={true}\n classNames={{\n root: \"oui-items-start\",\n }}\n onRow={(record, index) => {\n return {\n className: grayCell(record) ? \"oui-text-base-contrast-20\" : \"\",\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 (props.type === TabType.tp_sl) {\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 >\n {props.filterItems.length > 0 && (\n <Filter\n items={props.filterItems}\n onFilter={(value: any) => {\n props.onFilter(value);\n }}\n />\n )}\n\n <Pagination\n {...props.meta}\n onPageChange={props.setPage}\n onPageSizeChange={props.setPageSize}\n />\n </AuthGuardDataTable>\n </Flex>\n </OrderListProvider>\n );\n};\n","import {\n AlgoOrderRootType,\n API,\n OrderSide,\n OrderStatus,\n OrderType,\n} from \"@orderly.network/types\";\nimport {\n Box,\n Button,\n capitalizeFirstLetter,\n cn,\n Column,\n Flex,\n Text,\n} from \"@orderly.network/ui\";\nimport { commifyOptional, Decimal } from \"@orderly.network/utils\";\nimport { useMemo } from \"react\";\nimport {\n grayCell,\n parseBadgesFor,\n upperCaseFirstLetter,\n} from \"../../utils/util\";\nimport { TabType } from \"../orders.widget\";\nimport { Badge } from \"@orderly.network/ui\";\nimport { OrderQuantity } from \"./quantity\";\nimport { Price } from \"./price\";\nimport { TriggerPrice } from \"./triggerPrice\";\nimport { CancelButton } from \"./cancelBtn\";\nimport { Renew } from \"./renew\";\nimport { OrderTriggerPrice } from \"./tpslTriggerPrice\";\n\nexport const useOrderColumn = (_type: TabType) => {\n const columns =\n // useMemo(\n () => {\n switch (_type) {\n case TabType.all:\n return [\n instrument({ width: 130, showType: true }),\n side({ width: 130 }),\n fillAndQuantity({\n width: 130,\n disableEdit: true,\n className: \"oui-pl-0 oui-pr-0\",\n }),\n price({ width: 130, title: \"Order price\", disableEdit: true }),\n avgOpen({ width: 130 }),\n tpslTriggerPrice({ width: 130 }),\n estTotal({ width: 130 }),\n fee({ width: 130 }),\n status({ width: 130 }),\n reduceOnly({ width: 130 }),\n hidden({ width: 130 }),\n cancelBtn({ width: 130 }),\n ];\n case TabType.pending:\n return [\n instrument({ width: 162, showType: true }),\n side({ width: 162 }),\n fillAndQuantity({ width: 162, className: \"oui-pr-0\" }),\n price({ width: 162, className: \"oui-pr-0\" }),\n triggerPrice({ width: 162, className: \"oui-pr-0\" }),\n estTotal({ width: 162 }),\n reduceOnly({ width: 162 }),\n hidden({ width: 162 }),\n orderTime({ width: 162 }),\n cancelBtn({ width: 162 }),\n ];\n case TabType.tp_sl:\n return [\n instrument({ width: 176, showType: true }),\n side({ width: 176 }),\n quantity({ width: 176 }),\n tpslTriggerPrice({ width: 176 }),\n price({ width: 176, disableEdit: true }),\n notional({ width: 176 }),\n reduceOnly({ width: 176 }),\n orderTime({ width: 176 }),\n tpslAction({ width: 176 }),\n ];\n case TabType.filled:\n return [\n instrument({ width: 124 }),\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({ width: 124, title: \"Order price\", disableEdit: true }),\n avgPrice({ 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: 124 }),\n ];\n case TabType.cancelled:\n return [\n instrument({ showType: true, 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({ 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 ];\n case TabType.rejected:\n return [\n instrument({ showType: true, 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({ 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: 124 }),\n ];\n case TabType.orderHistory:\n return [\n instrument({ showType: true, 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({ 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: 124 }),\n cancelBtn({ width: 124 }),\n ];\n }\n };\n\n // }, [_type]);\n\n return columns();\n};\n\nfunction instrument(option?: {\n showType?: boolean;\n enableSort?: boolean;\n width?: number;\n}): Column<API.Order> {\n return {\n title: \"Instrument\",\n dataIndex: \"symbol\",\n className: \"oui-h-[48px]\",\n width: option?.width,\n onSort: option?.enableSort\n ? (r1, r2, sortOrder) => {\n if (sortOrder === \"asc\") {\n return r1.symbol.localeCompare(r2.symbol);\n }\n return r2.symbol.localeCompare(r1.symbol);\n }\n : undefined,\n render: (value: string, record) => {\n const badge =\n typeof record.type === \"string\"\n ? record.type.replace(\"_ORDER\", \"\").toLowerCase()\n : record.type;\n\n const showGray = grayCell(record);\n\n return (\n <Flex direction=\"column\" itemAlign={\"start\"}>\n <Text.formatted\n rule={\"symbol\"}\n size=\"xs\"\n className=\" oui-text-xs\"\n onClick={(e) => {\n // props.onSymbolChange?.({ symbol: value } as API.Symbol);\n e.stopPropagation();\n e.preventDefault();\n }}\n >\n {value}\n </Text.formatted>\n {option?.showType && (\n <Flex direction={\"row\"} gap={1}>\n {parseBadgesFor(record)?.map((e) => (\n <Badge\n color={\n e.toLocaleLowerCase() === \"position\"\n ? showGray\n ? \"neutural\"\n : \"primary\"\n : \"neutural\"\n }\n size=\"xs\"\n >\n {e}\n </Badge>\n ))}\n </Flex>\n )}\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: \"Side\",\n dataIndex: \"side\",\n width: option?.width,\n className: \"oui-h-[48px]\",\n onSort: option?.enableSort\n ? (r1, r2, sortOrder) => {\n if (sortOrder === \"asc\") {\n return r2.side.localeCompare(r1.side);\n }\n return r1.side.localeCompare(r2.side);\n }\n : undefined,\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: \"Type\",\n dataIndex: \"type\",\n width: option?.width,\n className: option?.className,\n formatter: (value: string, record: any) => {\n const type =\n typeof record.type === \"string\"\n ? record.type.replace(\"_ORDER\", \"\").toLowerCase()\n : record.type;\n if (record.algo_order_id) {\n return `Stop ${type}`;\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.Order> {\n return {\n title: \"Filled / Quantity\",\n dataIndex: \"fill_quantity\",\n className: option?.className,\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => {\n return <OrderQuantity order={record} disableEdit={option?.disableEdit} />;\n // return value;\n },\n };\n}\n\nfunction quantity(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"Quantity\",\n className: option?.className,\n dataIndex: \"quantity\",\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => {\n if (record.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n return \"Entire position\";\n }\n return <OrderQuantity 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}): Column<API.Order> {\n return {\n title: option?.title ?? \"Price\",\n dataIndex: \"price\",\n className: option?.className,\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => {\n return <Price order={record} disableEdit={option?.disableEdit} />;\n },\n };\n}\n\nfunction avgPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n}): Column<API.Order> {\n return {\n title: \"Avg. price\",\n dataIndex: \"average_executed_price\",\n className: option?.className,\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => {\n return <Text>{commifyOptional(value)}</Text>;\n },\n };\n}\n\nfunction triggerPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n}): Column<API.Order> {\n return {\n title: \"Trigger\",\n className: option?.className,\n dataIndex: \"trigger_price\",\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => (\n <TriggerPrice order={record} disableEdit={option?.disableEdit} />\n ),\n };\n}\n\nfunction tpslTriggerPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"Trigger\",\n className: option?.className,\n dataIndex: \"trigger_price\",\n width: option?.width,\n onSort: option?.enableSort,\n render: (value: string, record: any) => <OrderTriggerPrice />,\n };\n}\n\nfunction estTotal(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"Est. total\",\n dataIndex: \"executed\",\n width: option?.width,\n className: option?.className,\n render: (value: string, record: any) => {\n if (\n record.type === OrderType.CLOSE_POSITION &&\n record.status !== OrderStatus.FILLED\n ) {\n return \"Entire position\";\n }\n\n return (\n <Text.numeral rm={Decimal.ROUND_DOWN}>\n {record.total_executed_quantity === 0 ||\n Number.isNaN(record.average_executed_price) ||\n record.average_executed_price === null\n ? \"--\"\n : `${\n record.total_executed_quantity * record.average_executed_price\n }`}\n </Text.numeral>\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: \"Reduce only\",\n dataIndex: \"reduce_only\",\n width: option?.width,\n className: option?.className,\n render: (value: boolean) => {\n return <Text>{value ? \"Yes\" : \"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: \"Hidden\",\n dataIndex: \"visible\",\n width: option?.width,\n className: option?.className,\n render: (value: number, record) => {\n return <Text>{record.visible_quantity !== 0 ? \"No\" : \"Yes\"}</Text>;\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: \"Order time\",\n dataIndex: \"created_time\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\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: \"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: \"Notional\",\n dataIndex: \"notional\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n render: (value: string) => (\n <Text className=\"oui-break-normal oui-whitespace-nowrap oui-font-semibold\">\n {value}\n </Text>\n ),\n };\n}\n\nfunction status(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"Status\",\n dataIndex: \"status\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n render: (value: string, record: any) => (\n <Text className=\"oui-break-normal oui-whitespace-nowrap oui-font-semibold\">\n {capitalizeFirstLetter(\n (record?.algo_status || record.status)?.toLocaleLowerCase()\n )}\n </Text>\n ),\n };\n}\n\nfunction avgOpen(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"Avg. open\",\n dataIndex: \"average_open_price\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\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 cancelBtn(option?: {\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"\",\n dataIndex: \"\",\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 tpslAction(option?: {\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"\",\n dataIndex: \"\",\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 <Button size=\"sm\" variant={\"outlined\"} color={\"secondary\"}>\n Edit\n </Button>\n <CancelButton order={record} />\n </Flex>\n );\n },\n };\n}\n","import { API, OrderStatus } from \"@orderly.network/types\";\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\nexport enum AlgoOrderType {\n TAKE_PROFIT = \"TAKE_PROFIT\",\n STOP_LOSS = \"STOP_LOSS\",\n}\n\nexport enum AlgoOrderRootType {\n TP_SL = \"TP_SL\",\n POSITIONAL_TP_SL = \"POSITIONAL_TP_SL\",\n STOP = \"STOP\",\n}\n\nexport function parseBadgesFor(record: any): undefined | string[] {\n if (typeof record.type !== \"undefined\") {\n return typeof record.type === \"string\"\n ? [record.type.replace(\"_ORDER\", \"\").toLowerCase() as string]\n : [record.type as string];\n }\n\n if (typeof record.algo_type !== \"undefined\") {\n const list = new Array<string>();\n\n if (record.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n list.push(\"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(tpOrder && slOrder ? \"TP/SL\" : tpOrder ? \"TP\" : \"SL\");\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","import {\n FC,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { API, OrderSide } from \"@orderly.network/types\";\nimport { AlgoOrderRootType } from \"@orderly.network/types\";\nimport { cn, Flex, Popover, toast, Text } from \"@orderly.network/ui\";\nimport { OrderListContext } from \"./orderListContext\";\nimport { useTPSLOrderRowContext } from \"./tpslOrderRowContext\";\nimport { useSymbolContext } from \"./symbolProvider\";\nimport { grayCell } from \"../../utils/util\";\nimport { ConfirmContent, EditType } from \"./editOrder/confirmContent\";\nimport { InnerInput } from \"./editOrder/innerInput\";\n\nexport const OrderQuantity = (props: {\n order: API.OrderExt | API.AlgoOrder;\n disableEdit?: boolean;\n}) => {\n const { order } = props;\n\n const [quantity, originSetQuantity] = useState<string>(\n order.quantity.toString()\n );\n\n const [editting, setEditting] = useState(false);\n\n useEffect(() => {\n setQuantity(order.quantity.toString());\n }, [props.order.quantity]);\n\n const [open, setOpen] = useState(false);\n const [error, setError] = useState<string>();\n\n const { editOrder, editAlgoOrder, checkMinNotional } =\n useContext(OrderListContext);\n const { onUpdateOrder: onUpdateTPSLOrder, position } =\n useTPSLOrderRowContext();\n\n const { base_dp, base } = useSymbolContext();\n\n const setQuantity = (qty: string) => {\n originSetQuantity(qty);\n const positionQty = Math.abs(position?.position_qty || 0);\n if (position && Number(qty) > positionQty) {\n setError(\n `Quantity should be less than position quantity : ${positionQty}`\n );\n } else {\n setError(undefined);\n }\n };\n\n const closePopover = () => {\n setOpen(false);\n setEditting(false);\n };\n const cancelPopover = () => {\n setOpen(false);\n setQuantity(order.quantity.toString());\n setEditting(false);\n };\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const clickHandler = () => {\n console.log(\"xxxxx click handler\", checkMinNotional, quantity);\n\n if (!!error) {\n return;\n }\n\n if (Number(quantity) === Number(order.quantity)) {\n setEditting(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, quantity);\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: quantity,\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 !== undefined) {\n params = { ...params, order_tag: order.order_tag };\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) => {\n closePopover();\n setQuantity(quantity.toString());\n // setTimeout(() => inputRef.current?.blur(), 300);\n },\n (err) => {\n toast.error(err.message);\n setQuantity(order.quantity.toString());\n cancelPopover();\n }\n )\n .finally(() => setIsSubmitting(false));\n }, [quantity]);\n\n const componentRef = useRef<HTMLDivElement | null>(null);\n\n const handleClickOutside = (event: any) => {\n if (\n componentRef.current &&\n !componentRef.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]);\n\n const trigger = () => {\n if (!editting || props.disableEdit) {\n return (\n <NormalState\n order={order}\n quantity={quantity}\n setEditing={setEditting}\n disableEdit={props.disableEdit}\n />\n );\n }\n\n return (\n <InnerInput\n inputRef={inputRef}\n dp={base_dp}\n value={quantity}\n setPrice={setQuantity}\n setEditting={setEditting}\n handleKeyDown={handleKeyDown}\n onClick={onClick}\n onClose={cancelPopover}\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={quantity}\n cancelPopover={cancelPopover}\n isSubmitting={isSubmitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div ref={componentRef}>{trigger()}</div>\n </Popover>\n );\n};\n\nconst NormalState: FC<{\n order: API.AlgoOrder | API.OrderExt;\n quantity: string;\n setEditing: any;\n partial?: boolean;\n disableEdit?: boolean;\n}> = (props) => {\n const { order, quantity } = 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-max-w-[110px] oui-relative\",\n\n order.side === OrderSide.BUY && \"oui-text-trade-profit\",\n order.side === OrderSide.SELL && \"oui-text-trade-loss\",\n grayCell(order) && \"oui-text-base-conrast-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-min-w-[70px] oui-h-[28px]\",\n !props.disableEdit && \"oui-bg-base-7 oui-px-2\"\n )}\n >\n <Text size=\"2xs\">{quantity}</Text>\n </Flex>\n </Flex>\n );\n};\n","import { modal } from \"@orderly.network/ui\";\nimport { API, OrderEntity } from \"@orderly.network/types\";\nimport { FC, PropsWithChildren, createContext, useCallback } from \"react\";\n\nimport { checkNotional, useSymbolsInfo } from \"@orderly.network/hooks\";\n\nexport interface OrderListContextState {\n onCancelOrder: (order: API.Order | API.AlgoOrder) => Promise<any>;\n onEditOrder: (\n order: API.Order | API.AlgoOrder,\n position?: API.Position\n ) => 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 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 {\n cancelOrder,\n editOrder,\n cancelAlgoOrder,\n editAlgoOrder,\n // cancelTPSLOrder,\n } = props;\n const symbolInfo = useSymbolsInfo();\n const onCancelOrder = useCallback(\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\n const onEditOrder = useCallback(\n async (order: API.Order | API.AlgoOrder, position?: API.Position) => {\n // @ts-ignore\n let 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 const orderEntry = await modal.sheet({\n title: \"Edit Order\",\n contentClassName: \"orderly-edit-order-sheet-content\",\n content: (\n // <OrderEditFormSheet\n // order={order}\n // position={position}\n // editOrder={(value: OrderEntity) => {\n // /// check order has order_tag, if exits add order_tag to request body\n // if (\n // typeof order.order_tag !== undefined &&\n // order.reduce_only !== true\n // ) {\n // value = { ...value, order_tag: order.order_tag };\n // }\n // if (order.algo_order_id !== undefined) {\n // return editAlgoOrder(order.algo_order_id.toString(), {\n // ...value,\n // });\n // }\n // return editOrder((order as any).order_id.toString(), {\n // ...value,\n // ...(isHidden ? { visible_quantity: 0 } : {}),\n // });\n // }}\n // />\n <>Content</>\n ),\n });\n },\n []\n );\n\n const checkMinNotional = useCallback(\n (symbol: string, price?: string | number, qty?: string | number) => {\n const { min_notional } = symbolInfo[symbol]();\n return checkNotional(price, qty, min_notional);\n },\n [symbolInfo]\n );\n\n return (\n <OrderListContext.Provider\n value={{\n onCancelOrder,\n onEditOrder,\n editOrder,\n editAlgoOrder,\n checkMinNotional,\n }}\n >\n {props.children}\n </OrderListContext.Provider>\n );\n};\n","import {\n createContext,\n FC,\n PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { API } from \"@orderly.network/types\";\nimport {\n unstable_serialize,\n useAccount,\n useMutation,\n useSWRConfig,\n utils,\n} from \"@orderly.network/hooks\";\n\nexport type TPSLOrderRowContextState = {\n order: API.AlgoOrderExt;\n tp_trigger_price?: number;\n sl_trigger_price?: 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(\n {} as TPSLOrderRowContextState\n);\n\nexport const useTPSLOrderRowContext = () => {\n return useContext(TPSLOrderRowContext);\n};\n\nexport const TPSLOrderRowProvider: FC<\n PropsWithChildren<{\n order: API.AlgoOrderExt;\n }>\n> = (props) => {\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 = 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 = async (order: API.AlgoOrderExt, params: any) => {\n console.log(\"onUpdateOrder\", order, position);\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 const getRelatedPosition = (\n symbol: string\n ): API.PositionTPSLExt | undefined => {\n const positions = config.cache.get(positionKey);\n\n return positions?.data.rows.find(\n (p: API.PositionTPSLExt) => p.symbol === symbol\n );\n };\n\n const { sl_trigger_price, tp_trigger_price } = useMemo(() => {\n if (\n !(\"algo_type\" in props.order) ||\n !Array.isArray(props.order.child_orders)\n ) {\n return {};\n }\n return utils.findTPSLFromOrder(props.order);\n }, [props.order]);\n\n useEffect(() => {\n if (\"algo_type\" in props.order) {\n const position = getRelatedPosition(props.order.symbol);\n if (position) {\n setPosition(position);\n }\n }\n }, [props.order.symbol]);\n\n return (\n <TPSLOrderRowContext.Provider\n value={{\n order: props.order,\n sl_trigger_price,\n tp_trigger_price,\n onCancelOrder,\n onUpdateOrder,\n getRelatedPosition,\n position,\n }}\n >\n {props.children}\n </TPSLOrderRowContext.Provider>\n );\n};\n","import React, {\n FC,\n PropsWithChildren,\n createContext,\n useMemo,\n useContext,\n} from \"react\";\nimport { useSymbolsInfo } from \"@orderly.network/hooks\";\n\ninterface SymbolContextState {\n base_dp: number;\n quote_dp: number;\n base_tick: number;\n base: string;\n quote: string;\n symbol: string;\n}\n\nexport const SymbolContext = createContext({} as SymbolContextState);\n\nexport const useSymbolContext = () => {\n return useContext(SymbolContext);\n};\n\ninterface FormatterProviderProps {\n symbol: string;\n}\n\nexport const SymbolProvider: FC<PropsWithChildren<FormatterProviderProps>> = (\n props\n) => {\n const symbolInfo = useSymbolsInfo()[props.symbol];\n\n return (\n <SymbolContext.Provider\n value={{\n base_dp: symbolInfo(\"base_dp\"),\n quote_dp: symbolInfo(\"quote_dp\"),\n base_tick: symbolInfo(\"base_tick\"),\n base: symbolInfo(\"base\"),\n quote: symbolInfo(\"quote\"),\n symbol: props.symbol,\n }}\n >\n {props.children}\n </SymbolContext.Provider>\n );\n};\n","import { Button, CloseIcon } from \"@orderly.network/ui\";\nimport { commify } from \"@orderly.network/utils\";\nimport { FC, useMemo } from \"react\";\n\nexport enum EditType {\n quantity,\n price,\n triggerPrice,\n}\n\nexport const ConfirmContent: FC<{\n type: EditType;\n base: string;\n value: string;\n cancelPopover: () => void;\n isSubmitting: boolean;\n onConfirm: (e: any) => void;\n}> = (props) => {\n const { type, base, value, cancelPopover, isSubmitting, onConfirm } = props;\n\n const label = useMemo(() => {\n switch (type) {\n case EditType.quantity:\n return `You agree changing the quantity of ${base}-PERP order to${\" \"}`;\n case EditType.price:\n return `You agree changing the price of ${base}-PERP order to${\" \"}`;\n case EditType.triggerPrice:\n return `You agree changing the trigger price of ${base}-PERP order to${\" \"}`;\n }\n }, [type]);\n\n return (\n <div className=\"oui-pt-5 oui-relative\">\n <div className=\"oui-text-base-contrast-54 oui-text-2xs desktop:oui-text-sm\">\n {label}\n <span className=\"oui-text-warning\">{commify(value)}</span>.\n </div>\n <div className=\"oui-grid oui-grid-cols-2 oui-gap-2 oui-mt-5\">\n <Button\n color=\"secondary\"\n onClick={cancelPopover}\n disabled={isSubmitting}\n >\n Cancel\n </Button>\n <Button loading={isSubmitting} onClick={onConfirm}>\n Confirm\n </Button>\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={18} />\n </button>\n </div>\n );\n};\n","import { CheckIcon, CloseIcon, Input, inputFormatter, Tooltip } from \"@orderly.network/ui\";\nimport { FC, useEffect } from \"react\";\n\nexport const InnerInput: FC<{\n inputRef: any;\n value: string;\n setPrice: any;\n setEditting: any;\n error?: string;\n handleKeyDown: (e: any) => void;\n onClick: (e: any) => void;\n onClose: (e: any) => void;\n dp: number;\n hintInfo?: string;\n }> = (props) => {\n const {\n inputRef,\n dp,\n value,\n setPrice,\n setEditting,\n error,\n handleKeyDown,\n onClick,\n onClose,\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 setEditting(true);\n }, []);\n return (\n <Tooltip content={hintInfo} open={(hintInfo?.length || 0) > 0}>\n <Input\n ref={inputRef}\n type=\"text\"\n size=\"sm\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(dp),\n ]}\n value={value}\n onValueChange={(e) => setPrice(e)}\n helpText={error}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n onKeyDown={handleKeyDown}\n autoFocus\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 };","import { API } from \"@orderly.network/types\";\nimport { commifyOptional } from \"@orderly.network/utils\";\nimport { FC, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useSymbolPriceRange } from \"@orderly.network/hooks\";\nimport { cn, Flex, Popover, toast, Text } from \"@orderly.network/ui\";\nimport { OrderListContext } from \"./orderListContext\";\nimport { useSymbolContext } from \"./symbolProvider\";\nimport { grayCell } from \"../../utils/util\";\nimport { ConfirmContent, EditType } from \"./editOrder/confirmContent\";\nimport { InnerInput } from \"./editOrder/innerInput\";\n\nexport const Price = (props: {\n order: API.OrderExt;\n disableEdit?: boolean;\n}) => {\n const { order } = props;\n\n const [price, setPrice] = useState<string>(\n order.price?.toString() ?? \"Market\"\n );\n\n const [open, setOpen] = useState(false);\n const [editting, setEditting] = useState(false);\n\n const isAlgoOrder = order?.algo_order_id !== undefined;\n // console.log(\"price node\", order);\n\n const isStopMarket = order?.type === \"MARKET\" && isAlgoOrder;\n\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const { editOrder, editAlgoOrder, checkMinNotional } =\n useContext(OrderListContext);\n\n const { base, quote_dp } = useSymbolContext();\n const closePopover = () => {\n setOpen(false);\n setEditting(false);\n };\n const cancelPopover = () => {\n setOpen(false);\n setPrice(order.price?.toString() ?? \"Market\");\n setEditting(false);\n };\n\n const onClick = (event: any) => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (price === `${order.price}`) {\n setEditting(false);\n return;\n }\n\n if (order.reduce_only !== true) {\n const notionalText = checkMinNotional(\n order.symbol,\n price,\n order.quantity\n );\n if (notionalText) {\n toast.error(notionalText);\n setIsSubmitting(false);\n cancelPopover();\n return;\n }\n }\n\n setOpen(true);\n };\n\n const handleKeyDown = (event: any) => {\n if (event.key === \"Enter\") {\n onClick(event);\n }\n };\n\n const onConfirm = () => {\n setIsSubmitting(true);\n\n let order_id = order.order_id;\n let data: any = {\n order_price: price,\n order_quantity: order.quantity,\n symbol: order.symbol,\n order_type: order.type,\n side: order.side,\n // reduce_only: Boolean(order.reduce_only),\n };\n if (typeof order.reduce_only !== \"undefined\") {\n data.reduce_only = order.reduce_only;\n }\n\n if (order.order_tag !== undefined) {\n data = { ...data, order_tag: order.order_tag };\n }\n\n if (isAlgoOrder) {\n order_id = order.algo_order_id as number;\n data = {\n ...data,\n order_id,\n price: price,\n algo_order_id: order_id,\n };\n }\n\n if (order?.visible_quantity === 0) {\n data[\"visible_quantity\"] = 0;\n }\n\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(\n (result) => {\n closePopover();\n setPrice(price);\n // setTimeout(() => inputRef.current?.blur(), 300);\n },\n (err) => {\n toast.error(err.message);\n\n setPrice(order.price!.toString());\n cancelPopover();\n }\n )\n .finally(() => setIsSubmitting(false));\n };\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const rangeInfo = useSymbolPriceRange(\n order.symbol,\n // @ts-ignore\n order.side,\n isAlgoOrder ? order.trigger_price : undefined\n );\n\n const hintInfo = useMemo(() => {\n if (!rangeInfo) return \"\";\n if (isStopMarket) return \"\";\n if (!editting) return \"\";\n\n if (Number(price) > rangeInfo.max) {\n return `Price can not be greater than ${rangeInfo.max} USDC.`;\n }\n if (Number(price) < rangeInfo.min) {\n return `Price can not be less than ${rangeInfo.min} USDC.`;\n }\n return \"\";\n }, [isStopMarket, editting, rangeInfo, price]);\n\n useEffect(() => {\n {\n if (!!props.order.price) {\n setPrice(`${props.order.price}`);\n }\n }\n }, [props.order.price]);\n\n const componentRef = useRef<HTMLDivElement | null>(null);\n\n const handleClickOutside = (event: any) => {\n if (\n componentRef.current &&\n !componentRef.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]);\n\n const isAlgoMarketOrder = order.algo_order_id && order.type == \"MARKET\";\n\n \n if (isAlgoMarketOrder || price === \"Market\") {\n return <span>Market</span>;\n }\n\n const trigger = () => {\n if (!editting || props.disableEdit) {\n return (\n <NormalState\n order={order}\n price={price}\n setEditing={setEditting}\n disableEdit={props.disableEdit}\n />\n );\n }\n\n return (\n <InnerInput\n inputRef={inputRef}\n dp={quote_dp}\n value={price}\n setPrice={setPrice}\n setEditting={setEditting}\n handleKeyDown={handleKeyDown}\n onClick={onClick}\n onClose={cancelPopover}\n hintInfo={hintInfo}\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={price}\n cancelPopover={cancelPopover}\n isSubmitting={isSubmitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div ref={componentRef}>{trigger()}</div>\n </Popover>\n );\n};\n\nconst NormalState: FC<{\n order: any;\n price: string;\n setEditing: any;\n disableEdit?: boolean;\n}> = (props) => {\n const { order, price } = props;\n\n return (\n <div\n className={cn(\n \"oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold\",\n grayCell(order) && \"oui-text-base-conrast-20\"\n )}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.setEditing(true);\n }}\n >\n <Flex\n r=\"base\"\n className={cn(\n \"oui-min-w-[70px] oui-h-[28px]\",\n !props.disableEdit && \"oui-bg-base-7 oui-px-2\"\n )}\n >\n <Text size=\"2xs\">{commifyOptional(price)}</Text>\n </Flex>\n </div>\n );\n};\n","import { API } from \"@orderly.network/types\";\nimport { FC, useContext, useEffect, useRef, useState } from \"react\";\nimport { cn, Flex, Popover, toast, Text } from \"@orderly.network/ui\";\nimport { OrderListContext } from \"./orderListContext\";\nimport { useSymbolContext } from \"./symbolProvider\";\nimport { grayCell } from \"../../utils/util\";\nimport { ConfirmContent, EditType } from \"./editOrder/confirmContent\";\nimport { InnerInput } from \"./editOrder/innerInput\";\n\nexport const TriggerPrice = (props: {\n order: API.OrderExt;\n disableEdit?: boolean;\n}) => {\n const { order } = props;\n\n const [price, setPrice] = useState<string>(\"\");\n\n useEffect(() => {\n setPrice(order.trigger_price?.toString() ?? \"0\");\n }, [order.trigger_price]);\n\n const isAlgoOrder = order?.algo_order_id !== undefined;\n const [open, setOpen] = useState(false);\n const [editting, setEditting] = useState(false);\n\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const { editAlgoOrder, checkMinNotional } = useContext(OrderListContext);\n\n const { base, quote_dp } = useSymbolContext();\n const closePopover = () => {\n setOpen(false);\n setEditting(false);\n };\n const cancelPopover = () => {\n setPrice(order.trigger_price?.toString() ?? \"0\");\n setOpen(false);\n setEditting(false);\n };\n\n const componentRef = useRef<HTMLDivElement | null>(null);\n\n const handleClickOutside = (event: any) => {\n if (\n componentRef.current &&\n !componentRef.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]);\n\n const onClick = (event: any) => {\n event?.stopPropagation();\n event?.preventDefault();\n\n setEditting(false);\n\n if (Number(price) === Number(order.trigger_price)) {\n return;\n }\n\n if (order.price && order.reduce_only !== true) {\n const notionalText = checkMinNotional(\n order.symbol,\n order.price,\n order.quantity\n );\n if (notionalText) {\n toast.error(notionalText);\n setIsSubmitting(false);\n cancelPopover();\n return;\n }\n }\n\n setOpen(true);\n };\n\n const handleKeyDown = (event: any) => {\n if (event.key === \"Enter\") {\n onClick(event);\n }\n };\n\n const onConfirm = () => {\n setIsSubmitting(true);\n\n let data: any = {\n // price: price,\n quantity: order.quantity,\n trigger_price: price,\n symbol: order.symbol,\n // order_type: order.type,\n // side: order.side,\n // reduce_only: Boolean(order.reduce_only),\n algo_order_id: order.algo_order_id,\n };\n\n if (order.order_tag !== undefined) {\n data = { ...data, order_tag: order.order_tag };\n }\n\n editAlgoOrder(`${order.algo_order_id}`, data)\n .then(\n (result) => {\n closePopover();\n setPrice(price);\n // setTimeout(() => inputRef.current?.blur(), 300);\n },\n (err) => {\n toast.error(err.message);\n\n setPrice(order.trigger_price?.toString() ?? \"--\");\n cancelPopover();\n }\n )\n .finally(() => setIsSubmitting(false));\n };\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n if (!isAlgoOrder) {\n return <Text>{`--`}</Text>;\n }\n const trigger = () => {\n if (!editting || props.disableEdit) {\n return (\n <NormalState\n order={order}\n price={price}\n setEditing={setEditting}\n disableEdit={props.disableEdit}\n />\n );\n }\n\n return (\n <InnerInput\n inputRef={inputRef}\n dp={quote_dp}\n value={price}\n setPrice={setPrice}\n setEditting={setEditting}\n handleKeyDown={handleKeyDown}\n onClick={onClick}\n onClose={cancelPopover}\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={price}\n cancelPopover={cancelPopover}\n isSubmitting={isSubmitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div ref={componentRef}>{trigger()}</div>\n </Popover>\n );\n};\n\nconst NormalState: FC<{\n order: any;\n price: string;\n setEditing: any;\n disableEdit?: boolean;\n}> = (props) => {\n const { order, price } = props;\n\n return (\n <div\n className={cn(\n \"oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold\",\n grayCell(order) && \"oui-text-base-conrast-20\"\n )}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.setEditing(true);\n }}\n >\n <Flex\n r=\"base\"\n className={cn(\n \"oui-min-w-[70px] oui-h-[28px]\",\n !props.disableEdit && \"oui-bg-base-7 oui-px-2\"\n )}\n >\n <Text size=\"2xs\">{price}</Text>\n </Flex>\n </div>\n );\n};\n","import { API } from \"@orderly.network/types\";\nimport { Button, toast } from \"@orderly.network/ui\";\nimport { FC, useContext, useState } from \"react\";\nimport { OrderListContext } from \"./orderListContext\";\n\nexport const CancelButton: FC<{\n order: API.Order;\n}> = (props) => {\n const { order } = props;\n\n const { onCancelOrder } = useContext(OrderListContext);\n const [isLoading, setIsLoading] = useState(false);\n\n return (\n <Button\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) => res,\n (error) => {\n toast.error(error.message);\n }\n )\n .finally(() => {\n setIsLoading(false);\n });\n }}\n loading = {isLoading}\n >\n Cancel\n </Button>\n );\n};\n","import { FC, useCallback, useContext, useMemo, useState } from \"react\";\n\nimport { useConfig, useMutation } from \"@orderly.network/hooks\";\nimport { OrderEntity } from \"@orderly.network/types\";\nimport { Button } from \"@orderly.network/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 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 // visible_quantity: record.visible,\n side: record.side,\n // reduce_only: record.reduce_only,\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 doCreateOrder(data);\n }, []);\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 Renew\n </Button>\n );\n};\n","import { FC, useMemo } from \"react\";\nimport { useSymbolsInfo, utils } from \"@orderly.network/hooks\";\nimport { API, AlgoOrderType } from \"@orderly.network/types\";\nimport { OrderSide } from \"@orderly.network/types\";\nimport { cn, Text, Tooltip } from \"@orderly.network/ui\"\nimport { useTPSLOrderRowContext } from \"./tpslOrderRowContext\";\n\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\n\nconst 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\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\"\n )}\n key={\"tp\"}\n rule=\"price\"\n precision={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 TP&nbsp;-&nbsp;\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 \"\n )}\n rule={\"price\"}\n precision={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 SL&nbsp;-&nbsp;\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]);\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 <Tooltip content={pnl}>{content}</Tooltip>;\n }\n\n return content;\n};\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 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\n return (\n <div className=\"oui-flex oui-items-center\">\n <span className=\"oui-text-base-contrast-54 oui-mr-1\">{`${type} PnL:`}</span>\n <Text.numeral\n rule=\"price\"\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 surfix={\n <span className=\"oui-text-base-contrast-36 oui-ml-1\">\n USDC\n </span>\n }\n >{`${Math.abs(pnl)}`}</Text.numeral>\n </div>\n );\n};","import { useMemo, useState } from \"react\";\nimport {\n AlgoOrderRootType,\n OrderStatus,\n OrderSide,\n} from \"@orderly.network/types\";\nimport { useOrderStream } from \"@orderly.network/hooks\";\nimport { TabType } from \"../orders.widget\";\nimport { DataFilterItems, usePagination } from \"@orderly.network/ui\";\nimport { differenceInDays, setHours } from \"date-fns\";\n\nexport const useOrderListScript = (props: {\n type: TabType;\n ordersStatus?: OrderStatus;\n}) => {\n const { ordersStatus, type } = props;\n\n const { page, pageSize, setPage, setPageSize, parseMeta } = usePagination();\n const { orderStatus, ordersSide, dateRange, filterItems, onFilter } =\n useFilter(type, {\n ordersStatus,\n setPage,\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\n const [\n data,\n {\n isLoading,\n loadMore,\n cancelOrder,\n updateOrder,\n cancelAlgoOrder,\n updateAlgoOrder,\n meta,\n },\n ] = useOrderStream({\n status: orderStatus,\n side: ordersSide,\n page: page,\n size: pageSize,\n dateRange,\n includes,\n excludes,\n });\n\n return {\n type,\n dataSource: data,\n isLoading,\n loadMore,\n cancelOrder,\n updateOrder,\n cancelAlgoOrder,\n updateAlgoOrder,\n\n // pagination\n page,\n pageSize,\n setPage,\n setPageSize,\n meta: parseMeta(meta),\n\n // filter\n onFilter,\n filterItems,\n };\n};\n\nconst useFilter = (\n type: TabType,\n option: {\n setPage: (page: number) => void;\n ordersStatus?: OrderStatus;\n }\n) => {\n const [orderStatus, setOrderStatus] = useState<OrderStatus | undefined>(\n option.ordersStatus\n );\n const [ordersSide, setOrdersSide] = useState<OrderSide | undefined>(\n undefined\n );\n const [dateRange, setDateRange] = useState<{\n from?: Date;\n to?: Date;\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(filter.value);\n option.setPage(1);\n }\n };\n\n const filterItems = useMemo((): any[] => {\n const sideFilter = {\n type: \"select\",\n name: \"side\",\n options: [\n {\n label: \"All sides\",\n value: undefined,\n },\n {\n label: \"Buy\",\n value: \"BUY\",\n },\n {\n label: \"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: \"All status\",\n value: undefined,\n },\n {\n label: \"Pending\",\n value: OrderStatus.INCOMPLETE,\n },\n {\n label: \"Canceled\",\n value: OrderStatus.CANCELLED,\n },\n {\n label: \"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];\n }\n }, [type, ordersSide, orderStatus, dateRange]);\n\n return {\n filterItems,\n onFilter,\n ordersSide,\n dateRange,\n orderStatus,\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","import { OrderStatus } from \"@orderly.network/types\";\nimport { useOrderListScript } from \"./orderList.script\";\nimport { OrderList } from \"./orderList.ui\";\nimport { TabType } from \"../orders.widget\";\n\nexport const OrderListWidget = (props: {\n type: TabType;\n ordersStatus?: OrderStatus;\n}) => {\n const state = useOrderListScript(props);\n return (\n <OrderList {...state}/>\n );\n};\n","import { FC } from \"react\";\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 const OrdersWidget: FC<{\n current?: TabType;\n}> = (props) => {\n const state = useOrdersScript(props);\n\n return <Orders {...state} />;\n};\n"]}
File without changes
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@orderly.network/ui-orders",
3
+ "version": "2.0.0-alpha.1",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "keywords": [
9
+ "Orderly",
10
+ "Exchange",
11
+ "DeFi"
12
+ ],
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "dependencies": {
20
+ "date-fns": "^3.6.0",
21
+ "@orderly.network/ui": "2.0.0-alpha.1",
22
+ "@orderly.network/ui-connector": "2.0.0-alpha.1",
23
+ "@orderly.network/hooks": "2.0.0-alpha.1",
24
+ "@orderly.network/types": "2.0.0-alpha.1",
25
+ "@orderly.network/utils": "2.0.0-alpha.1",
26
+ "@orderly.network/ui-positions": "2.0.0-alpha.1"
27
+ },
28
+ "devDependencies": {
29
+ "@types/react": "^18.3.2",
30
+ "@types/react-dom": "^18.3.0",
31
+ "react": "^18.3.1",
32
+ "react-dom": "^18.2.0",
33
+ "tailwindcss": "^3.4.4",
34
+ "tsup": "^7.1.0",
35
+ "typescript": "^5.1.6",
36
+ "tsconfig": "0.3.12"
37
+ },
38
+ "scripts": {
39
+ "build": "tsup && pnpm run build:css",
40
+ "build:css": "tailwindcss build -i src/tailwind.css -o dist/styles.css --minify",
41
+ "test": "echo \"Error: no test specified\" && exit 1"
42
+ }
43
+ }