@orderly.network/trading 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var react$1 = require('@orderly.network/react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var reactApp = require('@orderly.network/react-app');
6
+ require('@orderly.network/react/dist/styles.css');
7
+ var ui = require('@orderly.network/ui');
8
+ var hooks = require('@orderly.network/hooks');
9
+ var uiPositions = require('@orderly.network/ui-positions');
10
+ var uiOrders = require('@orderly.network/ui-orders');
11
+ var types = require('@orderly.network/types');
12
+ var utils = require('@orderly.network/utils');
13
+ var react = require('react');
14
+ var uiConnector = require('@orderly.network/ui-connector');
15
+ var uiTransfer = require('@orderly.network/ui-transfer');
16
+ var lucideReact = require('lucide-react');
17
+ var uiLeverage = require('@orderly.network/ui-leverage');
18
+ var uiTradingview = require('@orderly.network/ui-tradingview');
19
+
20
+ var{Header:$n,Content:zo}=react$1.Layout,{mobile:qo,desktop:Vo}=react$1.TradingPage,ht=e=>jsxRuntime.jsx(react$1.TradingPageProvider,{symbol:e.symbol,onSymbolChange:e.onSymbolChange,disableFeatures:e.disableFeatures,shareOptions:e.shareOptions,referral:e.referral,tradingReward:e.tradingReward,wrongNetwork:e.wrongNetwork,children:jsxRuntime.jsx(react$1.Layout,{mobile:jsxRuntime.jsx(qo,{...e}),children:jsxRuntime.jsx(react$1.Layout,{style:{paddingBottom:"42px"},children:jsxRuntime.jsx(zo,{children:jsxRuntime.jsx(Vo,{...e})})})})});var Pt=e=>{let{wrongNetwork:t}=reactApp.useAppContext();return jsxRuntime.jsx(ht,{...e,wrongNetwork:t})};var _o=e=>jsxRuntime.jsx(Pt,{...e});var kt=e=>{let{current:t,config:o}=e,[r,i]=hooks.useLocalStorage("unPnlPriceBasis","markPrice"),[n,a]=hooks.useLocalStorage("pnlNotionalDecimalPrecision",2),[s,c]=hooks.useLocalStorage("showAllSymbol",!0);return {current:t,config:o,unPnlPriceBasis:r,setUnPnlPriceBasic:i,pnlNotionalDecimalPrecision:n,setPnlNotionalDecimalPrecision:a,showAllSymbol:s,setShowAllSymbol:c}};var Ae=e=>jsxRuntime.jsxs(ui.Flex,{px:3,py:2,gap:6,width:"100%",justify:"start",children:[jsxRuntime.jsx(ui.Statistic,{label:"Unreal. PnL",children:jsxRuntime.jsxs(ui.Flex,{children:[jsxRuntime.jsx(ui.Text.numeral,{coloring:!0,dp:e.pnlNotionalDecimalPrecision,rm:utils.Decimal.ROUND_DOWN,children:e.unrealPnL}),e.unrealPnlROI&&jsxRuntime.jsx(ui.Text.numeral,{coloring:!0,prefix:"(",suffix:")",rule:"percentages",dp:e.pnlNotionalDecimalPrecision,rm:utils.Decimal.ROUND_DOWN,children:e.unrealPnlROI})]})}),jsxRuntime.jsx(ui.Statistic,{label:"Notional",children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.pnlNotionalDecimalPrecision,rm:utils.Decimal.ROUND_DOWN,children:e.notional})})]});var St=e=>{let{pnlNotionalDecimalPrecision:t,unPnlPriceBasis:o,symbol:r}=e,i=o,[n]=hooks.usePositionStream(r,{calcMode:i}),a=reactApp.useDataTap(n.aggregated),s=a?.unrealPnL,c=a?.unrealPnlROI,d=a?.notional;return {pnlNotionalDecimalPrecision:t,unrealPnL:s,unrealPnlROI:c,notional:d}};var Me=e=>{let t=St(e);return jsxRuntime.jsx(Ae,{...t})};var Le=e=>{let[t,o]=react.useState(!1);return jsxRuntime.jsxs(ui.Flex,{gap:0,children:[jsxRuntime.jsxs(ui.Flex,{gap:1,children:[jsxRuntime.jsx(ui.Checkbox,{color:"white",checked:e.showAllSymbol,onCheckedChange:r=>{e.setShowAllSymbol(r);}}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,children:"Show all instruments"})]}),jsxRuntime.jsx(ui.Button,{size:"xs",type:"button",variant:"contained",className:"oui-bg-transparent hover:oui-bg-transparent",children:jsxRuntime.jsxs(ui.DropdownMenuRoot,{open:t,onOpenChange:o,children:[jsxRuntime.jsx(ui.DropdownMenuTrigger,{children:jsxRuntime.jsx(ui.SettingFillIcon,{size:16,color:"white"})}),jsxRuntime.jsx(ui.DropdownMenuContent,{className:"oui-p-2",alignOffset:2,align:"end",children:jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-col oui-text-3xs",children:[jsxRuntime.jsx(ui.Text,{className:"oui-text-xs oui-pb-3",children:"Portfolio Settings"}),jsxRuntime.jsx(ui.Divider,{}),jsxRuntime.jsx(ui.Text,{className:"oui-pb-3 oui-text-base-contrast-54 oui-mt-2",children:"Decimal Precision for PnL & Notional"}),jsxRuntime.jsx(tr,{value:e.pnlNotionalDecimalPrecision,onValueChange:r=>{e.setPnlNotionalDecimalPrecision(r),o(!1);}}),jsxRuntime.jsx(ui.Divider,{className:"oui-my-3"}),jsxRuntime.jsx(ui.Text,{className:"oui-pb-3 oui-text-base-contrast-54 oui-mt-2",children:"Unrealized PnL Price Basis"}),jsxRuntime.jsx(er,{value:e.unPnlPriceBasis,onValueChange:r=>{e.setUnPnlPriceBasic(r),o(!1);}})]})})]})})]})},er=e=>{let{value:t,onValueChange:o}=e;return jsxRuntime.jsxs(ui.Flex,{gap:2,children:[jsxRuntime.jsx(Y,{sel:t==="markPrice",label:"Mark price",value:"markPrice",onCheckChange:o}),jsxRuntime.jsx(Y,{sel:t==="lastPrice",label:"Last price",value:"lastPrice",onCheckChange:o})]})},tr=e=>{let{value:t,onValueChange:o}=e;return jsxRuntime.jsxs(ui.Flex,{gap:2,children:[jsxRuntime.jsx(Y,{sel:t===0,label:1,value:0,onCheckChange:o}),jsxRuntime.jsx(Y,{sel:t===1,label:.1,value:1,onCheckChange:o}),jsxRuntime.jsx(Y,{sel:t===2,label:.01,value:2,onCheckChange:o})]})},Y=e=>{let{sel:t,label:o,value:r,onCheckChange:i}=e;return jsxRuntime.jsxs(ui.Flex,{onClick:n=>{i(r),n.stopPropagation();},gap:1,className:"oui-cursor-pointer",children:[t?jsxRuntime.jsx(or,{}):jsxRuntime.jsx(rr,{}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:t?98:54,children:o})]})},or=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"oui-fill-white",children:[jsxRuntime.jsx("path",{d:"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"3.333"})]}),rr=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667",fill:"#fff",fillOpacity:".54"})});var wt=e=>{let{pnlNotionalDecimalPrecision:t,setPnlNotionalDecimalPrecision:o,unPnlPriceBasis:r,setUnPnlPriceBasic:i,showAllSymbol:n,setShowAllSymbol:a}=e;return {pnlNotionalDecimalPrecision:t,setPnlNotionalDecimalPrecision:o,unPnlPriceBasis:r,setUnPnlPriceBasic:i,showAllSymbol:n,setShowAllSymbol:a}};var Re=e=>{let t=wt(e);return jsxRuntime.jsx(Le,{...t})};var qe=e=>jsxRuntime.jsxs(ui.Tabs,{defaultValue:e.current||"Positions",variant:"contained",trailing:jsxRuntime.jsx(Re,{pnlNotionalDecimalPrecision:e.pnlNotionalDecimalPrecision,setPnlNotionalDecimalPrecision:e.setPnlNotionalDecimalPrecision,unPnlPriceBasis:e.unPnlPriceBasis,setUnPnlPriceBasic:e.setUnPnlPriceBasic,showAllSymbol:e.showAllSymbol,setShowAllSymbol:e.setShowAllSymbol}),children:[jsxRuntime.jsx(ui.TabPanel,{value:"Positions",title:"Positions",children:jsxRuntime.jsx(ur,{...e})}),jsxRuntime.jsx(ui.TabPanel,{value:"Pending",title:"Pending",children:jsxRuntime.jsx(uiOrders.OrderListWidget,{type:uiOrders.TabType.pending,ordersStatus:types.OrderStatus.INCOMPLETE})}),jsxRuntime.jsx(ui.TabPanel,{value:"TP/SL",title:"TP/SL",children:jsxRuntime.jsx(uiOrders.OrderListWidget,{type:uiOrders.TabType.tp_sl,ordersStatus:types.OrderStatus.INCOMPLETE})}),jsxRuntime.jsx(ui.TabPanel,{value:"Filled",title:"Filled",children:jsxRuntime.jsx(uiOrders.OrderListWidget,{type:uiOrders.TabType.filled,ordersStatus:types.OrderStatus.FILLED})}),jsxRuntime.jsx(ui.TabPanel,{value:"Order history",title:"Order history",children:jsxRuntime.jsx(uiOrders.OrderListWidget,{type:uiOrders.TabType.orderHistory})})]}),ur=e=>jsxRuntime.jsxs(ui.Flex,{direction:"column",children:[jsxRuntime.jsx(Me,{pnlNotionalDecimalPrecision:e.pnlNotionalDecimalPrecision,symbol:e.config?.symbol,unPnlPriceBasis:e.unPnlPriceBasis}),jsxRuntime.jsx(ui.Divider,{className:"oui-w-full"}),jsxRuntime.jsx(uiPositions.PositionsWidget,{...e.config,pnlNotionalDecimalPrecision:e.pnlNotionalDecimalPrecision})]});var Ve=e=>{let t=kt(e);return jsxRuntime.jsx(qe,{...t})};var Ee=e=>jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",className:ui.cn("oui-font-semibold",e.className),width:"100%",height:"100%",style:e.style,children:[jsxRuntime.jsx(fr,{base:e.base,quote:e.quote}),jsxRuntime.jsx(gr,{data:e.data,isLoading:e.isLoading,baseDp:e.baseDp,quoteDp:e.quoteDp})]}),It=e=>{let{key:t,left:o,mid:r,right:i,classNames:n}=e;return jsxRuntime.jsxs(ui.Flex,{height:20,gap:2,width:"100%",className:ui.cn("oui-text-xs oui-tabular-nums",n?.root),children:[jsxRuntime.jsx(ui.Box,{className:ui.cn("oui-flex-1",n?.left),children:o}),jsxRuntime.jsx(ui.Box,{className:ui.cn("oui-flex-1",n?.mid),children:r}),jsxRuntime.jsx(ui.Box,{className:ui.cn("oui-flex-1 oui-text-right",n?.right),children:i})]},t)},fr=e=>jsxRuntime.jsx(It,{left:"Time",mid:`Price(${e.quote})`,right:`Qty(${e.base})`,classNames:{root:"oui-text-base-contrast-54 oui-h-[32px]"}}),gr=e=>jsxRuntime.jsx(ui.ScrollArea,{className:"oui-w-full oui-h-full",children:e.data?.map((t,o)=>jsxRuntime.jsx(It,{left:jsxRuntime.jsx(ui.Text.formatted,{rule:"date",formatString:"HH:mm:ss",children:t?.ts}),mid:utils.commifyOptional(t?.price,{fix:e.quoteDp}),right:utils.commifyOptional(t?.size,{fix:e.baseDp}),classNames:{left:"oui-text-base-contrast-80",right:t.side===types.OrderSide.BUY?"oui-text-trade-profit":"oui-text-trade-loss",mid:t.side===types.OrderSide.BUY?"oui-text-trade-profit":"oui-text-trade-loss"}},o))});var Mt=e=>{let{data:t,isLoading:o}=hooks.useMarketTradeStream(e),r=hooks.useSymbolsInfo()?.[e],i=r?.("base"),n=r?.("quote"),a=r?.("base_dp"),s=r?.("quote_dp");return {base:i,quote:n,data:t,isLoading:o,baseDp:a,quoteDp:s}};var me=e=>{let t=Mt(e.symbol);return jsxRuntime.jsx(Ee,{...t,className:e.className,style:e.style})};var Or=()=>{let{state:e}=hooks.useAccount(),{wrongNetwork:t}=reactApp.useAppContext();return react.useMemo(()=>{if(t)return {title:"Wrong Network",description:"Please switch to a supported network to continue.",titleColor:"warning"};switch(e.status){case types.AccountStatusEnum.NotConnected:return {title:"Connect wallet",description:"Please connect your wallet before starting to trade."};case types.AccountStatusEnum.NotSignedIn:return {title:"Sign in",description:"Please sign in before starting to trade.",titleColor:"primaryLight"};case types.AccountStatusEnum.DisabledTrading:return {title:"Enable trading",description:"Enable trading before starting to trade.",titleColor:"primaryLight"};default:return {title:"",description:""}}},[e.status,t])},Ir=({totalValue:e=0,visible:t=!0,onToggleVisibility:o})=>jsxRuntime.jsxs(ui.Flex,{direction:"column",gap:1,className:"oui-text-2xs",itemAlign:"center",children:[jsxRuntime.jsx(ui.Text.numeral,{visible:t,weight:"bold",size:"2xl",className:ui.gradientTextVariants({color:"brand"}),as:"div",padding:!1,children:e??"--"}),jsxRuntime.jsxs(ui.Flex,{gap:1,itemAlign:"center",children:[jsxRuntime.jsx(ui.Text,{size:"2xs",color:"neutral",weight:"semibold",children:"My Assets (USDC)"}),jsxRuntime.jsx("button",{onClick:()=>o?.(),children:t?jsxRuntime.jsx(ui.EyeIcon,{size:18,className:"oui-text-base-contrast-54"}):jsxRuntime.jsx(ui.EyeCloseIcon,{size:18,className:"oui-text-base-contrast-54"})})]})]}),Ar=({visible:e=!0,freeCollateral:t,marginRatioVal:o,renderMMR:r,isConnected:i})=>{let[n,a]=hooks.useLocalStorage("orderly_entry_asset_list_open",!1),[s,c]=react.useState(n);return jsxRuntime.jsxs(ui.Box,{children:[jsxRuntime.jsxs(ui.Flex,{justify:"center",gap:1,itemAlign:"center",className:"oui-cursor-pointer",onClick:()=>{c(d=>!d),a(!s);},children:[jsxRuntime.jsx(ui.Divider,{className:"oui-flex-1"}),jsxRuntime.jsx(ui.ChevronDownIcon,{size:18,color:"white",className:react$1.cn("oui-transition-transform",s&&"oui-rotate-180")}),jsxRuntime.jsx(ui.Divider,{className:"oui-flex-1"})]}),jsxRuntime.jsx(react$1.Collapsible,{open:s,children:jsxRuntime.jsx(react$1.CollapsibleContent,{children:jsxRuntime.jsxs(ui.Box,{className:"oui-space-y-1.5",children:[jsxRuntime.jsxs(ui.Flex,{justify:"between",children:[jsxRuntime.jsx(ui.Tooltip,{content:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{children:"Free collateral for placing new orders."}),jsxRuntime.jsx(ui.Divider,{className:"oui-py-2 oui-border-white/10"}),jsxRuntime.jsx("span",{children:"Free collateral = Total balance + Total unsettlement PnL - Total position initial margin"})]}),children:jsxRuntime.jsx(ui.Text,{size:"2xs",color:"neutral",weight:"semibold",className:"oui-cursor-pointer",children:"Free collateral"})}),jsxRuntime.jsx(ui.Text.numeral,{visible:e,size:"2xs",unit:"USDC",unitClassName:"oui-text-base-contrast-36",as:"div",padding:!1,children:t??"--"})]}),jsxRuntime.jsxs(ui.Flex,{justify:"between",children:[jsxRuntime.jsx(ui.Tooltip,{content:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{children:"Your actual Leverage of the whole account / Your max Leverage of the whole account"}),jsxRuntime.jsx(ui.Divider,{className:"oui-py-2 oui-border-white/10"}),jsxRuntime.jsx("span",{children:"Margin ratio = Total collateral / Total position notional"})]}),children:jsxRuntime.jsx(ui.Text,{size:"2xs",color:"neutral",weight:"semibold",className:"oui-cursor-pointer",children:"Margin ratio"})}),i?jsxRuntime.jsx(ui.Text.numeral,{size:"2xs",unitClassName:"oui-text-base-contrast-36",as:"div",rule:"percentages",padding:!1,children:o}):jsxRuntime.jsx(ui.Text,{className:"oui-text-base-contrast-36",children:"--"})]}),jsxRuntime.jsxs(ui.Flex,{justify:"between",children:[jsxRuntime.jsx(ui.Tooltip,{content:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{children:"Maintenance margin ratio."}),jsxRuntime.jsx(ui.Divider,{className:"oui-py-2 oui-border-white/10"}),jsxRuntime.jsx("span",{children:"Maintenance margin ratio = ..."})]}),children:jsxRuntime.jsx(ui.Text,{size:"2xs",color:"neutral",weight:"semibold",className:"oui-cursor-pointer",children:"Maintenance margin ratio"})}),r?jsxRuntime.jsx(ui.Text.numeral,{size:"2xs",suffix:"%",unitClassName:"oui-text-base-contrast-36",as:"div",padding:!1,children:r}):jsxRuntime.jsx(ui.Text,{className:"oui-text-base-contrast-36",children:"--"})]})]})})})]})},$e=({networkId:e,isFirstTimeDeposit:t,totalValue:o,onDeposit:r,onWithdraw:i,toggleVisible:n,visible:a,freeCollateral:s,marginRatioVal:c,renderMMR:d,isConnected:u})=>{let m=Or(),{title:b,description:v}=m,w=m.titleColor??"";return jsxRuntime.jsxs(ui.Box,{children:[b&&v?jsxRuntime.jsxs(ui.Flex,{direction:"column",gap:1,className:"oui-mb-[32px]",children:[w?jsxRuntime.jsx(ui.Text,{size:"lg",weight:"bold",color:w,children:b}):jsxRuntime.jsx(ui.Text.gradient,{size:"lg",weight:"bold",color:"brand",children:b}),jsxRuntime.jsx(ui.Text,{size:"2xs",color:"neutral",weight:"semibold",children:v})]}):null,jsxRuntime.jsx(uiConnector.AuthGuard,{networkId:e,status:types.AccountStatusEnum.EnableTrading,buttonProps:{size:"md",fullWidth:!0},children:t?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Box,{children:jsxRuntime.jsxs(ui.Flex,{direction:"column",gap:1,className:"oui-mb-[32px]",children:[jsxRuntime.jsx(ui.Text.gradient,{size:"lg",weight:"bold",color:"brand",children:"Deposit to start trade"}),jsxRuntime.jsx(ui.Text,{size:"2xs",color:"neutral",weight:"semibold",children:"You can deposit assets from various networks"})]})}),jsxRuntime.jsxs(ui.Button,{fullWidth:!0,size:"md",onClick:r,children:[jsxRuntime.jsx(ui.ArrowDownShortIcon,{color:"white",opacity:1}),jsxRuntime.jsx(ui.Text,{children:"Deposit"})]})]}):jsxRuntime.jsxs(ui.Box,{className:"oui-space-y-4",children:[jsxRuntime.jsx(Ir,{totalValue:o,visible:a,onToggleVisibility:n}),jsxRuntime.jsx(Ar,{visible:a,freeCollateral:s,marginRatioVal:c,renderMMR:d,isConnected:u}),jsxRuntime.jsxs(ui.Flex,{gap:3,itemAlign:"center",children:[jsxRuntime.jsxs(ui.Button,{fullWidth:!0,color:"secondary",size:"md",onClick:i,children:[jsxRuntime.jsx(ui.ArrowDownShortIcon,{color:"white",opacity:1,className:"oui-rotate-180"}),jsxRuntime.jsx(ui.Text,{children:"Withdraw"})]}),jsxRuntime.jsxs(ui.Button,{fullWidth:!0,size:"md",onClick:r,children:[jsxRuntime.jsx(ui.ArrowDownShortIcon,{color:"white",opacity:1}),jsxRuntime.jsx(ui.Text,{children:"Deposit"})]})]})]})})]})};var Yr=()=>{let{state:e}=hooks.useAccount(),{wrongNetwork:t}=reactApp.useAppContext(),{totalValue:o}=hooks.useCollateral({dp:2}),r=t||e.status<types.AccountStatusEnum.EnableTrading,i=react.useMemo(()=>{let a=new Date,s=new Date;s.setDate(a.getDate()-90);let c=s.getTime(),d=a.getTime(),u=new URLSearchParams;return u.set("page","1"),u.set("size","5"),u.set("side","DEPOSIT"),u.set("status","COMPLETED"),u.set("startTime",c.toString()),u.set("endTime",d.toString()),`/v1/asset/history?${u.toString()}`},[]),{data:n}=hooks.usePrivateQuery(i,{formatter:a=>a});return {isFirstTimeDeposit:!r&&o===0&&n?.meta?.total===0,totalValue:o}},Et=()=>{let e=hooks.useAccountInstance(),t=hooks.useMediaQuery(types.MEDIA_TABLET),{isFirstTimeDeposit:o,totalValue:r}=Yr(),i=hooks.useConfig("networkId"),{state:n}=hooks.useAccount(),{freeCollateral:a}=hooks.useCollateral({dp:2}),{marginRatio:s,mmr:c}=hooks.useMarginRatio(),d=n.status>=types.AccountStatusEnum.Connected,u=s===0?10:Math.min(s,10),m=react.useMemo(()=>c?new utils.Decimal(c).mul(100).todp(2,0).toFixed(2):"--",[c]),b=react.useCallback(async x=>{let y;return t?y=await ui.modal.show(uiTransfer.DepositAndWithdrawWithSheetId,{activeTab:x}):y=await ui.modal.show(uiTransfer.DepositAndWithdrawWithDialogId,{activeTab:x}),y},[t]),v=react.useCallback(async()=>b("deposit"),[t]),w=hooks.useEventEmitter(),P=react.useCallback(async()=>b("withdraw"),[t]),O=react.useCallback(async()=>e.settle().catch(x=>{if(x.code===-1104)return ui.toast.error("Settlement is only allowed once every 10 minutes. Please try again later."),Promise.reject(x)}).then(x=>(ui.toast.success("Settlement requested"),Promise.resolve(x))),[e]),[B,C]=hooks.useLocalStorage("orderly_assets_visible",!0),M=react.useCallback(()=>{C(x=>!x);},[B]);return hooks.useWalletSubscription({onMessage:x=>{let{side:y,transStatus:le}=x;if(le==="COMPLETED"){let _=`${utils.capitalizeString(y)} completed`;ui.toast.success(_);}else if(le==="FAILED"){let _=`${utils.capitalizeString(y)} failed`;ui.toast.error(_);}w.emit("wallet:changed",x);}}),hooks.useSettleSubscription({onMessage:x=>{let{status:y}=x;switch(y){case"COMPLETED":ui.toast.success("Settlement completed");break;case"FAILED":ui.toast.error("Settlement failed");break;}}}),{onDeposit:v,onWithdraw:P,onSettle:O,visible:B,toggleVisible:M,networkId:i,isFirstTimeDeposit:o,totalValue:r,status:n.status,freeCollateral:a,marginRatioVal:u,renderMMR:m,isConnected:d}};var Ue=()=>{let e=Et();return jsxRuntime.jsx($e,{...e})};var $=react.createContext({cellHeight:22}),D=()=>react.useContext($),fe=e=>{let[t,o]=react.useState("quantity"),[r,i]=react.useState("quantity");return jsxRuntime.jsx($.Provider,{value:{cellHeight:e.cellHeight,onItemClick:e.onItemClick,mode:t,totalMode:r||"quantity",depth:e.depth,onModeChange:o,onTotalModeChange:i,showTotal:e.showTotal||!1,pendingOrders:e.pendingOrders,symbolInfo:e.symbolInfo},children:e.children})};var ge=e=>{let{direction:t=1}=e,o=react.useMemo(()=>{let r=Math.max(e.width,0);return t===0?{transform:`translateX(${r}%)`}:{transform:`translateX(-${r}%)`}},[e.width]);return jsxRuntime.jsx("div",{className:ui.cn("oui-absolute oui-right-[-100%] oui-top-0 oui-h-full oui-w-full oui-transition-transform oui-pointer-events-none",t===0&&"oui-left-[-100%]",e.className),style:o})};var $t=e=>{let{cellHeight:t,showTotal:o,onItemClick:r,depth:i,pendingOrders:n}=D(),{symbolInfo:a,currentHover:s}=e,{base_dp:c,quote_dp:d}=a,u=Number.isNaN(e.price)?0:e.accumulated/e.count*100,m=react.useMemo(()=>utils.getPrecisionByNumber(i||`${d}`),[i,d]),b=Number.isNaN(e.accumulated)?"-":e.accumulatedAmount?.toString(),v=react.useMemo(()=>{let w=ui.parseNumber(e.price,{dp:m,padding:!0});return n.findIndex(O=>w===ui.parseNumber(O,{dp:m,padding:!0}))!==-1},[n,e.price,i]);return jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-row oui-pl-3 oui-tabular-nums oui-justify-between oui-text-base-contrast-80 oui-text-3xs oui-relative oui-cursor-pointer",style:{height:`${t}px`},onClick:()=>{Number.isNaN(e.price)||Number.isNaN(e.quantity)||r?.([e.price,e.quantity]);},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,children:[jsxRuntime.jsxs("div",{className:ui.cn("oui-basis-7/12 oui-flex oui-felx-row oui-items-center oui-mr-2",o&&"oui-basis-5/12"),children:[jsxRuntime.jsx("div",{className:ui.cn("oui-flex-1 oui-text-left",e.type==="ask"?"oui-text-trade-loss":"oui-text-trade-profit"),children:jsxRuntime.jsx(ui.Text.numeral,{dp:m,children:e.price})}),jsxRuntime.jsx("div",{className:"oui-flex-1 oui-text-right oui-text-base-contrast-80",children:jsxRuntime.jsx(ui.Text.numeral,{dp:c,children:e.quantity})})]}),jsxRuntime.jsxs("div",{className:ui.cn("oui-basis-5/12 oui-flex oui-items-center oui-fex-row oui-overflow-hidden oui-relative",o&&"oui-basis-7/12"),children:[jsxRuntime.jsx("div",{className:ui.cn("oui-flex-1 oui-pr-6 oui-text-right",o&&"oui-pr-3"),children:jsxRuntime.jsx(ui.Text.numeral,{dp:c,className:"oui-z-10",children:e.accumulated})}),o&&jsxRuntime.jsx("div",{className:"oui-flex-1 oui-text-right oui-pr-3",children:jsxRuntime.jsx(ui.Text.numeral,{dp:2,className:"oui-z-10",children:b})}),jsxRuntime.jsx(ge,{width:u,direction:0,className:e.type==="ask"?"oui-bg-trade-loss/10":"oui-bg-trade-profit/10"})]}),v&&jsxRuntime.jsx("div",{className:ui.cn("oui-absolute oui-rounded-full oui-left-[-8px] oui-h-[4px] oui-w-[4px] oui-pointer-events-none",e.type==="ask"&&"oui-bg-trade-loss",e.type==="bid"&&"oui-bg-trade-profit"),style:{top:`${t/2-2}px`}}),e.isHover&&jsxRuntime.jsx("div",{className:"oui-absolute oui-bg-white oui-left-0 oui-right-0 oui-top-0 oui-bottom-0 oui-opacity-[.12]"}),s&&jsxRuntime.jsx("div",{className:ui.cn("oui-absolute oui-left-0 oui-right-0",e.type==="ask"&&"oui-top-0",e.type==="bid"&&"oui-bottom-0"),children:jsxRuntime.jsx(ui.Divider,{lineStyle:"dashed",className:ui.cn("oui-w-full",e.type==="bid"&&"oui-border-trade-profit",e.type==="ask"&&"oui-border-trade-loss")})})]})};var be=e=>{let{data:t,type:o}=e,{symbolInfo:r,depth:i}=D(),n=react.useCallback(()=>{if((t?.length||0)===0)return null;if(o==="ask"){let u=t.findIndex(m=>!Number.isNaN(m[0]));return u!=-1?t[u]:null}else {for(let u=t.length-1;u>=0;u--){let m=t[u];if(!Number.isNaN(m[0]))return m}return null}},[t,o]),a=react.useMemo(()=>i?.toString().includes(".")?i.toString().split(".")[1].length:0,[i]),s=react.useMemo(()=>t.reduce((u,m)=>Math.max(u,m[1]),0),[t]),[c,d]=react.useState(-1);return jsxRuntime.jsx("div",{id:"oui-order-book-list",className:"oui-flex oui-flex-col oui-gap-[1px]",children:t.map((u,m)=>jsxRuntime.jsx(mi,{index:m,item:u,countQty:e.countQty,setHoverIndex:d,hoverIndex:c,type:o,maxQty:s,priceDp:a,symbolInfo:r,findMaxItem:n},m))})},mi=e=>{let{index:t,item:o,setHoverIndex:r,type:i,maxQty:n,hoverIndex:a,priceDp:s,symbolInfo:c}=e,{base:d,quote:u,base_dp:m,quote_dp:b}=c,v=a!==-1?i==="ask"?t>=a:t<=a:!1,[w,P]=react.useState(!1),O=C=>{if(C===null)return {sumQty:0,sumQtyAmount:0,avgPrice:0};let M={sumQty:0,sumQtyAmount:0};return Number.isNaN(C[2])||(M={sumQty:C[2],sumQtyAmount:C[3]}),{...M,avgPrice:M.sumQtyAmount==0?0:M.sumQtyAmount/M.sumQty}},B=O(o);return B.avgPrice===0&&(B=O(e.findMaxItem())),jsxRuntime.jsxs(ui.TooltipRoot,{open:w,onOpenChange:P,children:[jsxRuntime.jsx(ui.TooltipTrigger,{children:jsxRuntime.jsx($t,{background:"",price:o[0],quantity:o[1],accumulated:o[2],count:e.countQty,type:e.type,accumulatedAmount:o[3],maxQty:n,isHover:v,currentHover:a===t,symbolInfo:c,onMouseEnter:()=>{r(t),P(!0);},onMouseLeave:()=>{r(-1),P(!1);}})}),jsxRuntime.jsxs(ui.TooltipContent,{className:"oui-max-w-[400px] oui-w-full oui-text-2xs oui-shadow-md oui-rounded-base oui-p-3 oui-bg-base-6 oui-flex oui-flex-col oui-gap-2",align:"center",side:"left",sideOffset:12,onPointerEnter:C=>C.preventDefault(),children:[jsxRuntime.jsx(Ge,{title:"Avg. Price\u2248",content:B.avgPrice,contentDp:s}),jsxRuntime.jsx(Ge,{title:`Sum (${d})`,content:B.sumQty,contentDp:m}),jsxRuntime.jsx(Ge,{title:`Sum (${u})`,content:B.sumQtyAmount,contentDp:b}),jsxRuntime.jsx(ui.TooltipArrow,{className:"oui-fill-base-6"})]})]})},Ge=e=>{let{title:t,content:o,contentDp:r}=e;return jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-row oui-justify-between oui-gap-4",children:[jsxRuntime.jsx("div",{className:"oui-text-base-contrast-36",children:t}),jsxRuntime.jsx("div",{className:"oui-text-right",children:jsxRuntime.jsx(ui.Text.numeral,{dp:r,children:o})})]})};var Gt=e=>{let{data:t}=e,o=react.useMemo(()=>{let r=Number.NaN,i=t.length-1;for(;Number.isNaN(r)&&i>0;)r=t[i][2],i--;return r},[t]);return jsxRuntime.jsx(be,{type:"bid",data:t,countQty:o})};var Yt=e=>{let{data:t}=e,o=react.useMemo(()=>{let r=Number.NaN,i=t.length,n=0;for(;Number.isNaN(r)&&n<i;)r=t[n][2],n++;return r},[t]);return jsxRuntime.jsx(be,{type:"ask",data:t,countQty:o})};var jt=e=>{let{markPrice:t=0,lastPrice:o,asks:r,bids:i,symbolInfo:n}=e,{showTotal:a}=D();return jsxRuntime.jsxs(ui.Flex,{py:1,pl:3,pr:a?3:6,justify:"between",children:[jsxRuntime.jsxs(ui.Flex,{gap:2,children:[jsxRuntime.jsx(Ze,{markPrice:t,lastPrice:o,quote_dp:n.quote_dp}),jsxRuntime.jsx(Je,{markPrice:t,quote_dp:n.quote_dp})]}),jsxRuntime.jsx(Pi,{asks:r,bids:i})]})},Ze=e=>{let{markPrice:t=0,lastPrice:o,quote_dp:r,className:i,iconSize:n=18}=e,[a,s]=o;return jsxRuntime.jsxs(ui.Flex,{gap:1,className:ui.cn(s>a?"oui-text-trade-profit":"oui-text-trade-loss",i),children:[jsxRuntime.jsx(ui.Text.numeral,{dp:r,children:s}),jsxRuntime.jsxs(ui.Box,{width:19,children:[s<a&&jsxRuntime.jsx(ui.ArrowDownShortIcon,{size:n,color:"danger",opacity:1}),s>a&&jsxRuntime.jsx(ui.ArrowUpShortIcon,{size:n,color:"success",opacity:1})]})]})},Je=e=>{let{quote_dp:t,className:o,iconSize:r=18}=e;return jsxRuntime.jsx(ui.Tooltip,{content:"Obtained from a third-party oracle, the mark price is calculated as the median of three prices: the last price, the fair price based on the funding rate basis, and the fair price based on the order books.",className:"oui-max-w-[270px]",children:jsxRuntime.jsxs(ui.Flex,{gap:1,className:ui.cn("oui-cursor-pointer oui-text-2xs",o),children:[jsxRuntime.jsx(ki,{size:r}),jsxRuntime.jsx(ui.Text.numeral,{dp:t,color:"warning",className:"oui-underline oui-decoration-dashed oui-decoration-1 oui-underline-offset-4 oui-decoration-warning",children:e.markPrice})]})})},Pi=e=>{let{asks:t,bids:o}=e,r=react.useMemo(()=>{if(o.length===0&&t.length===0)return 0;let i=Number.isNaN(o[0][0])?0:o[0][0],n=t.reverse().findIndex(c=>!Number.isNaN(c[0])),a=0;n!==-1&&(a=Number.isNaN(t[n][0])?0:t[n][0]);let s=new utils.Decimal(a).sub(i).div(new utils.Decimal(a).add(i).div(2));return Math.ceil(s.toNumber()*1e6+.1)/1e4},[t,o]);return jsxRuntime.jsx("div",{children:jsxRuntime.jsx(ui.Tooltip,{content:"Spread Ratio of the ask1 and bid1.",className:"oui-max-w-[240px]",children:jsxRuntime.jsx(ui.Text,{size:"2xs",intensity:36,className:"oui-cursor-pointer oui-underline oui-decoration-dashed oui-decoration-1 oui-underline-offset-4 oui-decoration-base-contrast-36",children:`${r}%`})})})},ki=e=>jsxRuntime.jsx("svg",{width:e.size,height:e.size,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M3.75 1.5a.75.75 0 0 1 .75.75h6a.75.75 0 0 1 .75.75v1.5h3a.75.75 0 0 1 .75.75V12a.75.75 0 0 1-.75.75H7.5a.75.75 0 0 1-.75-.75v-1.5H4.5v5.25a.75.75 0 0 1-1.5 0V2.25a.75.75 0 0 1 .75-.75M4.5 9h5.25V3.75H4.5zm6.75-3v3.75a.75.75 0 0 1-.75.75H8.25v.75h5.25V6z",fill:"#FF7D00"})});var eo=e=>{let{showTotal:t}=react.useContext($);return jsxRuntime.jsxs(ui.Flex,{pl:3,justify:"between",className:"oui-py-[6px]",children:[jsxRuntime.jsxs(ui.Flex,{gap:1,className:ui.cn("oui-basis-7/12",t&&"oui-basis-1/2"),children:[jsxRuntime.jsx(ui.Box,{width:"100%",children:jsxRuntime.jsx(he,{name:"Price",token:e.quote,id:"oui-order-book-header-price"})}),jsxRuntime.jsx(ui.Box,{width:"100%",children:jsxRuntime.jsx(he,{name:"Qty",token:e.base,id:"oui-order-book-header-qty",justifyEnd:!0})})]}),jsxRuntime.jsxs(ui.Flex,{gap:1,pr:3,className:ui.cn("oui-basis-5/12",t&&"oui-basis-1/2"),children:[jsxRuntime.jsx(ui.Box,{width:"100%",children:jsxRuntime.jsx(he,{name:"Total",token:e.base,id:"oui-order-book-header-total-base",justifyEnd:!0})}),t&&jsxRuntime.jsx(ui.Box,{width:"100%",children:jsxRuntime.jsx(he,{name:"Total",token:e.quote,id:"oui-order-book-header-total-quote",justifyEnd:!0})})]})]})},he=e=>{let{name:t,token:o,justifyEnd:r=!1}=e;return jsxRuntime.jsxs(ui.Flex,{id:e.id,className:ui.cn("oui-text-base-contrast-36 oui-text-xs oui-items-end",r&&"oui-justify-end"),children:[jsxRuntime.jsx("span",{children:t}),jsxRuntime.jsx("span",{children:`(${o})`})]})};var oo=e=>{let t=react.useMemo(()=>e.depths.map(o=>({value:o,label:`${o}`})),[e.depths]);return jsxRuntime.jsx(ui.Box,{pl:3,width:97,className:"oui-py-[10px]",children:jsxRuntime.jsx(ui.Select.options,{options:t,size:"xs",value:e.value,onValueChange:o=>{e.onChange?.(o);}})})};var ro=e=>{let{lastPrice:t,markPrice:o,quote:r,base:i,isLoading:n,onDepthChange:a}=e,s=react.useRef(null),[c,d]=react.useState(!1),u=[{left:370,right:600},{left:740,right:800}];return react.useEffect(()=>{let m=new ResizeObserver(v=>{for(let w of v){let {inlineSize:P}=w.borderBoxSize[0];u.reduce((B,C)=>B+(P>=C.left&&P<C.right?1:0),0);d(P>=360);}}),b=s.current;return b&&m.observe(b),()=>{b&&m.unobserve(b);}},[]),jsxRuntime.jsx(fe,{cellHeight:e.cellHeight??20,onItemClick:e.onItemClick,depth:e.activeDepth,showTotal:c,pendingOrders:e.pendingOrders||[],symbolInfo:e.symbolInfo,children:jsxRuntime.jsxs("div",{id:"oui-orderbook-desktop",className:ui.cn("oui-h-full oui-w-full oui-relative",e.className),ref:s,children:[jsxRuntime.jsx(oo,{depths:e.depths,value:e.activeDepth,onChange:a}),jsxRuntime.jsx(eo,{quote:r,base:i}),jsxRuntime.jsx(Yt,{data:[...e.asks]}),jsxRuntime.jsx(jt,{lastPrice:t,markPrice:o,asks:[...e.asks],bids:[...e.bids],symbolInfo:e.symbolInfo}),jsxRuntime.jsx(Gt,{data:[...e.bids]}),n&&jsxRuntime.jsx("div",{className:"oui-absolute oui-left-0 oui-top-0 oui-right-0 oui-bottom-0 oui-z-10 oui-flex oui-items-center oui-justify-center oui-bg-bg-8/70",children:jsxRuntime.jsx(ui.Spinner,{})})]})})};var no=e=>{let{mode:t,onModeChange:o}=D(),r=react.useMemo(()=>t==="amount"?e.quote:e.base,[t,e.quote,e.base]),i=react.useMemo(()=>t==="amount"?"Value":"Qty",[t]);return jsxRuntime.jsxs(ui.Flex,{justify:"between",width:"100%",className:"oui-text-base-contrast-36 oui-text-2xs oui-py-[5px]",children:[jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",id:"oui-order-book-header-price",children:[jsxRuntime.jsx(ui.Text,{children:"Price"}),jsxRuntime.jsx(ui.Text,{children:`(${e.quote})`})]}),jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"end",className:"oui-cursor-pointer",onClick:()=>o?.(t==="amount"?"quantity":"amount"),children:[jsxRuntime.jsx(ui.Text,{children:i}),jsxRuntime.jsx(ui.Text,{children:`(${r})`})]})]})};var lo=e=>{let t=e.accumulated/e.count*100,{cellHeight:o,onItemClick:r,depth:i,showTotal:n,symbolInfo:a}=react.useContext($),{base_dp:s,quote_dp:c}=a,d=Number.isNaN(e.quantity)?"-":e.mode==="amount"?new utils.Decimal(e.quantity).mul(e.price).toString():e.quantity;n&&(d=e.quantity);let u=react.useMemo(()=>utils.getPrecisionByNumber(i||`${c}`),[i,c]);return jsxRuntime.jsxs(ui.Box,{className:ui.cn("oui-overflow-hidden oui-relative oui-cursor-pointer oui-tabular-nums oui-text-2xs oui-w-full",n&&"oui-flex-1"),style:{height:`${o}px`},onClick:m=>{Number.isNaN(e.price)||Number.isNaN(e.quantity)||r?.([e.price,e.quantity]);},children:[jsxRuntime.jsxs(ui.Flex,{justify:"between",children:[jsxRuntime.jsx(ui.Text.numeral,{color:e.type==="bid"?"buy":"sell",dp:u,children:e.price}),jsxRuntime.jsx(ui.Text.numeral,{dp:e.mode==="amount"?2:s,className:"oui-text-base-contrast-80",children:d})]}),Number.isNaN(t)||n?null:jsxRuntime.jsx(ge,{width:t,className:e.type==="ask"?"oui-bg-trade-loss/20":"oui-bg-trade-profit/20"})]})};var Ne=e=>{let{data:t}=e,{mode:o}=D();return jsxRuntime.jsx(ui.Box,{id:"oui-order-book-list",className:"oui-flex oui-flex-col oui-gap-[1px] oui-w-full",children:t.map((r,i)=>jsxRuntime.jsx(lo,{background:"",price:r[0],quantity:r[1],accumulated:r[2],count:e.countQty,type:e.type,mode:o},i))})};var co=e=>{let{data:t}=e,o=react.useMemo(()=>{let r=Number.NaN,i=t.length-1;for(;Number.isNaN(r)&&i>0;)r=t[i][2],i--;return r},[t]);return jsxRuntime.jsx(Ne,{type:"bid",data:t,countQty:o})};var mo=e=>{let{data:t}=e,o=react.useMemo(()=>{let r=Number.NaN,i=t.length,n=0;for(;Number.isNaN(r)&&n<i;)r=t[n][2],n++;return r},[t]);return jsxRuntime.jsx(Ne,{type:"ask",data:t,countQty:o})};var fo=e=>{let {symbolInfo:r}=D(),{quote_dp:i}=r;return jsxRuntime.jsxs(ui.Flex,{id:"oui-order-book-mark-price",className:"oui-py-[6px]",width:"100%",justify:"between",children:[jsxRuntime.jsx(Ze,{markPrice:e.markPrice,lastPrice:e.lastPrice,quote_dp:i,className:"oui-text-sm",iconSize:14}),jsxRuntime.jsx(Je,{markPrice:e.markPrice,quote_dp:i,className:"oui-text-2xs",iconSize:12})]})};var po=e=>{let t=react.useMemo(()=>e.depth.map(o=>({value:o,label:`${o}`})),[e.depth]);return jsxRuntime.jsx(ui.Box,{id:"oui-order-book-depth",className:"oui-pt-2",children:jsxRuntime.jsx(ui.Picker,{options:t,fullWidth:!0,size:"sm",value:e.value,className:"oui-text-2xs oui-text-base-contrast-54 ",onValueChange:o=>{e.onChange?.(o);}})})};var it=e=>{let t=e.data.est_funding_rate,o=e.data.countDown;return jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",pb:2,children:[jsxRuntime.jsx(ui.Text,{intensity:36,size:"2xs",children:"Pred. funding rate"}),t===null?"--":jsxRuntime.jsxs("div",{className:"orderly-flex orderly-gap-1 oui-text-2xs",children:[jsxRuntime.jsx("span",{className:"orderly-text-warning",children:`${t}%`}),jsxRuntime.jsx("span",{children:"in"}),jsxRuntime.jsx("span",{children:o})]})]})};var nt=e=>({data:hooks.useFundingRate(e)});var at=e=>{let t=nt(e.symbol);return jsxRuntime.jsx(it,{...t})};var xo=e=>{let{lastPrice:t,markPrice:o,quote:r,base:i,isLoading:n,onDepthChange:a}=e,s=`PERP_${e.symbolInfo.base}_${e.symbolInfo.quote}`;return jsxRuntime.jsx(fe,{cellHeight:e.cellHeight??20,onItemClick:e.onItemClick,depth:e.activeDepth,pendingOrders:[],showTotal:!1,symbolInfo:e.symbolInfo,children:jsxRuntime.jsxs(ui.Flex,{direction:"column",p:2,id:"oui-orderbook-mobile",className:ui.cn("oui-h-full oui-wfull oui-relative",e.className),justify:"start",itemAlign:"start",children:[jsxRuntime.jsx(at,{symbol:s}),jsxRuntime.jsx(no,{quote:r,base:i}),jsxRuntime.jsx(mo,{data:e.asks}),jsxRuntime.jsx(fo,{lastPrice:t,markPrice:o}),jsxRuntime.jsx(co,{data:e.bids}),jsxRuntime.jsx(po,{depth:e.depths||[],value:e.activeDepth,onChange:a}),n&&jsxRuntime.jsx("div",{className:"oui-absolute oui-left-0 oui-top-0 oui-right-0 oui-bottom-0 oui-z-10 oui-flex oui-items-center oui-justify-center oui-bg-base-800/70 oui-h-full oui-min-h-[420px]",children:jsxRuntime.jsx(ui.Spinner,{})})]})})};var lt=e=>jsxRuntime.jsx(ui.Box,{className:"oui-font-semibold",width:"100%",height:"100%",children:e.isMWeb?jsxRuntime.jsx(xo,{level:e.level,asks:e.asks,bids:e.bids,markPrice:e.markPrice,lastPrice:e.lastPrice,depths:e.depths,activeDepth:e.selDepth,base:e.base,quote:e.quote,isLoading:e.isLoading,onItemClick:e.onItemClick,cellHeight:e.cellHeight,onDepthChange:e.onDepthChange,className:e.className,symbolInfo:e.symbolInfo}):jsxRuntime.jsx(ro,{level:e.level,asks:e.asks,bids:e.bids,markPrice:e.markPrice,lastPrice:e.lastPrice,depths:e.depths,activeDepth:e.selDepth,base:e.base,quote:e.quote,isLoading:e.isLoading,onItemClick:e.onItemClick,cellHeight:e.cellHeight,onDepthChange:e.onDepthChange,className:e.className,pendingOrders:e.pendingOrders,symbolInfo:e.symbolInfo})});var re=e=>({base_dp:e("base_dp"),quote_dp:e("quote_dp"),base_tick:e("base_tick"),base:e("base"),quote:e("quote")});var ie=20,Po=104,ct=e=>{let{symbol:t,height:o}=e,r=hooks.useSymbolsInfo()[e.symbol],[i,n]=react.useState(ie),[a,s]=react.useState(10),{base:c,quote:d,quote_dp:u}=re(r),[m,{onDepthChange:b,isLoading:v,onItemClick:w,depth:P,allDepths:O}]=hooks.useOrderbookStream(t,void 0,{level:a,padding:!1}),B=fn(t);react.useEffect(()=>{if(o){let y=Math.floor((o-Po)/((ie+1)*2)),le=(ie+1)*2*y,_=o-Po-le;_>10?n(ie+_/y/2):n(ie),s(y);}},[o]);let C=react.useMemo(()=>typeof P>"u"||typeof u>"u"?void 0:utils.removeTrailingZeros(P),[P,u]),M=react.useMemo(()=>O?.map(y=>utils.removeTrailingZeros(y))||[],[O,u]),x=hooks.useMediaQuery(types.MEDIA_TABLET);return {level:a,asks:m?.asks,bids:m?.bids,markPrice:m?.markPrice,lastPrice:m?.middlePrice,depths:M,selDepth:C,base:c,quote:d,isLoading:v,onItemClick:w,cellHeight:i,onDepthChange:b,pendingOrders:B,symbolInfo:re(r),isMWeb:x}},fn=e=>{let[t]=hooks.useOrderStream({status:types.OrderStatus.INCOMPLETE,symbol:e});return react.useMemo(()=>t?.filter(i=>i.symbol===e).reduce((i,n)=>{let a=n.price||n.trigger_price||0;return [...i,a]},[]),[t,e])};var ve=e=>{let t=ct({symbol:e.symbol,height:e.height});return jsxRuntime.jsx(lt,{...t,className:e.className})};var mt=e=>{let{riskRate:t,riskRateColor:o,isConnected:r,currentLeverage:i,maxLeverage:n}=e,{isHigh:a,isMedium:s,isLow:c,isDefault:d}=o,u=a?"oui-text-danger":s?"oui-text-warning":c?ui.gradientTextVariants({color:"brand"}):"";return jsxRuntime.jsxs(ui.Box,{"data-risk":"",className:"oui-space-y-2",children:[jsxRuntime.jsxs(ui.Flex,{itemAlign:"center",justify:"start",className:"oui-w-full oui-bg-base-6 oui-rounded-full oui-h-2 oui-px-[1px]",children:[d?jsxRuntime.jsx(ui.Box,{className:"oui-bg-gradient-to-r oui-opacity-20 oui-from-[#26fefe] oui-via-[#ff7d00] oui-to-[#d92d6b] oui-h-1.5 oui-rounded-full",style:{width:"100%"}}):null,a?jsxRuntime.jsx(ui.Box,{className:"oui-bg-gradient-to-tr oui-from-[#791438] oui-to-[#ff447c] oui-h-1.5 oui-rounded-full",style:{width:t}}):null,s?jsxRuntime.jsx(ui.Box,{className:"oui-bg-gradient-to-tr oui-from-[#792e00] oui-to-[#ffb65d] oui-h-1.5 oui-rounded-full",style:{width:t}}):null,c?jsxRuntime.jsx(ui.Box,{className:"oui-bg-gradient-to-tr oui-from-[#59b0fe] oui-to-[#26fefe] oui-h-1.5 oui-rounded-full",style:{width:t}}):null]}),jsxRuntime.jsxs(ui.Flex,{className:"oui-gap-2",children:[jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",className:"oui-flex-1",children:[jsxRuntime.jsx(ui.Tooltip,{content:jsxRuntime.jsx("div",{children:"hint test"}),children:jsxRuntime.jsx(ui.Text,{size:"2xs",color:"neutral",weight:"semibold",className:"oui-cursor-pointer",children:"Risk rate"})}),jsxRuntime.jsx(ui.Text,{size:"xs",color:"neutral",weight:"semibold",className:ui.cn(u),children:t})]}),jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"end",className:"oui-flex-1",children:[jsxRuntime.jsx(ui.Tooltip,{content:jsxRuntime.jsx("div",{children:"hint test"}),children:jsxRuntime.jsx(ui.Text,{size:"2xs",color:"neutral",weight:"semibold",className:"oui-cursor-pointer",children:"Max account leverage"})}),jsxRuntime.jsxs(ui.Flex,{className:"oui-gap-1",children:[r?jsxRuntime.jsx(ui.Text.numeral,{suffix:"x",children:i}):"--",jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54",children:"/"}),r?jsxRuntime.jsxs("button",{className:"oui-flex oui-items-center oui-gap-1",onClick:()=>{ui.modal.show(uiLeverage.LeverageWidgetId,{currentLeverage:5});},children:[jsxRuntime.jsx("span",{children:`${n??"--"}x`}),typeof n<"u"&&jsxRuntime.jsx(lucideReact.Pencil,{size:14,className:"oui-text-base-contrast-54"})]}):"--"]})]})]})]})};var Nn=e=>{if(e===null)return {isHigh:!1,isMedium:!1,isLow:!1,isDefault:!0};let t=e<40,o=e>=40&&e<80,r=e>=80;return {isHigh:r,isMedium:o,isLow:t,isDefault:!t&&!o&&!r}},No=()=>{let{state:e}=hooks.useAccount(),t=e.status>=types.AccountStatusEnum.Connected,{marginRatio:o,currentLeverage:r,mmr:i}=hooks.useMarginRatio(),[n]=hooks.useLeverage(),a=react.useMemo(()=>!t||o===null||i===null||o===0||i===0?"0%":`${new utils.Decimal(i).div(o).mul(100).todp(2,utils.Decimal.ROUND_UP).toString().replace(/\.?0+$/,"")}%`,[t,o,i]),s=a==="--"?null:parseFloat(a),c=react.useMemo(()=>Nn(s),[s]);return {riskRate:a,riskRateColor:c,isConnected:t,currentLeverage:r,maxLeverage:n}};var dt=()=>{let e=No();return jsxRuntime.jsx(mt,{...e})};var ft=e=>jsxRuntime.jsx("div",{ref:e.containerRef,className:"oui-h-full",children:(e.containerSize?.width||0)>=572?jsxRuntime.jsx(On,{...e}):jsxRuntime.jsx(In,{...e})}),On=e=>jsxRuntime.jsxs(ui.Grid,{cols:2,width:"100%",gap:3,className:"oui-auto-rows-fr",style:{height:e.containerSize?.height},children:[jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",pt:3,pb:3,r:"2xl",className:"oui-bg-base-9",children:[jsxRuntime.jsx(wo,{title:"Order book",className:"oui-pl-3"}),jsxRuntime.jsx(ve,{symbol:e.symbol,height:e.containerSize?e.containerSize.height-29-24:void 0})]}),jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",p:3,r:"2xl",className:"oui-bg-base-9 oui-h-full",children:[jsxRuntime.jsx(wo,{title:"Last trades"}),jsxRuntime.jsx(me,{symbol:e.symbol,style:{height:e.containerSize&&e.containerSize.height-29-24}})]})]}),In=e=>jsxRuntime.jsx(ui.Box,{pt:3,pb:3,pr:e.tab==="lastTrades"?3:0,r:"2xl",className:"oui-bg-base-9",style:{maxHeight:e.containerSize?.height},children:jsxRuntime.jsxs(ui.Tabs,{value:e.tab,variant:"contained",onValueChange:t=>{e.setTab(t);},children:[jsxRuntime.jsx(ui.TabPanel,{value:"orderBook",title:"Order book",children:jsxRuntime.jsx(ve,{symbol:e.symbol,height:e.containerSize?e.containerSize.height-29-18:void 0})}),jsxRuntime.jsx(ui.TabPanel,{value:"lastTrades",title:"Last trades",children:jsxRuntime.jsx(me,{symbol:e.symbol,style:{height:e.containerSize&&e.containerSize.height-29-18}})})]})}),wo=e=>jsxRuntime.jsx(ui.Text,{size:"base",intensity:80,className:ui.cn("oui-pb-[5px]",e.className),children:e.title});var gt=e=>{let[t,o]=react.useState(void 0),[r,i]=react.useState("orderBook"),n=react.useRef();return react.useEffect(()=>{let a=new ResizeObserver(c=>{for(let d of c){let{width:u,height:m}=d.contentRect;o({width:u,height:m});}}),s=n.current;return s&&a.observe(s),()=>{s&&a.unobserve(s);}},[]),{symbol:e,containerSize:t,containerRef:n,tab:r,setTab:i}};var pt=e=>{let t=gt(e.symbol);return jsxRuntime.jsx(ft,{...t})};var bt=e=>jsxRuntime.jsxs(ui.Flex,{direction:"column",gap:3,p:3,className:"oui-bg-base-10",children:[jsxRuntime.jsxs(ui.Flex,{p:3,width:"100%",height:600,gap:3,children:[jsxRuntime.jsx(ui.Box,{className:"oui-flex-1",width:"100%",height:"100%",children:jsxRuntime.jsx(uiTradingview.TradingviewWidget,{symbol:e.symbol,libraryPath:e.tradingViewConfig?.library_path,scriptSRC:e.tradingViewConfig?.scriptSRC,customCssUrl:e.tradingViewConfig?.customCssUrl})}),jsxRuntime.jsx(ui.Box,{className:"oui-flex-1",width:"100%",height:"100%",children:jsxRuntime.jsx(pt,{symbol:e.symbol})})]}),jsxRuntime.jsx(ui.Box,{className:"oui-bg-base-9 oui-rounded-2xl oui-p-3",children:jsxRuntime.jsx(Ve,{...e.dataList})}),jsxRuntime.jsx(ui.Box,{className:"oui-bg-base-9 oui-rounded-2xl oui-p-3 oui-space-y-8 oui-w-full",children:jsxRuntime.jsx(Ue,{})}),jsxRuntime.jsx(ui.Box,{className:"oui-bg-base-9 oui-rounded-2xl oui-p-3 oui-space-y-8 oui-w-full",children:jsxRuntime.jsx(dt,{})})]});var Oo=react.createContext({}),Io=()=>react.useContext(Oo),xt=e=>{let t=hooks.useSymbolsInfo()[e.symbol];return jsxRuntime.jsx(Oo.Provider,{value:{...e,symbolInfo:{...re(t),symbol:e.symbol}},children:e.children})};var Ao=()=>Io();var yt=()=>{let e=Ao();return jsxRuntime.jsx(bt,{...e})};var _n=e=>jsxRuntime.jsx(xt,{symbol:e.symbol,tradingViewConfig:e.tradingViewConfig,onSymbolChange:e.onSymbolChange,disableFeatures:e.disableFeatures,overrideFeatures:e.overrideFeatures,dataList:e.dataList,children:jsxRuntime.jsx(yt,{})});
21
+
22
+ exports.AssetView = $e;
23
+ exports.AssetViewWidget = Ue;
24
+ exports.DataList = qe;
25
+ exports.DataListWidget = Ve;
26
+ exports.LastTrades = Ee;
27
+ exports.LastTradesWidget = me;
28
+ exports.OrderBook = lt;
29
+ exports.OrderBookAndTrades = ft;
30
+ exports.OrderBookAndTradesWidget = pt;
31
+ exports.OrderBookWidget = ve;
32
+ exports.RiskRate = mt;
33
+ exports.RiskRateWidget = dt;
34
+ exports.TradingPage = _o;
35
+ exports.TradingPageProvider = xt;
36
+ exports.TradingPageV2 = _n;
37
+ exports.TradingV2 = bt;
38
+ exports.TradingV2Widget = yt;
39
+ exports.useOrderBookAndTradesScript = gt;
40
+ exports.useOrderBookScript = ct;
41
+ //# sourceMappingURL=out.js.map
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/pages/trading.ui.tsx","../src/pages/trading.widget.tsx","../src/pages/trading.page.tsx","../src/index.ts","../src/components/dataList/dataList.ui.tsx","../src/components/dataList/dataList.script.tsx","../src/components/dataList/positionHeader/positionHeader.ui.tsx","../src/components/dataList/positionHeader/positionHeader.script.tsx","../src/components/dataList/positionHeader/positionHeader.widget.tsx","../src/components/dataList/setting/setting.ui.tsx","../src/components/dataList/setting/setting.script.tsx","../src/components/dataList/setting/setting.widget.tsx","../src/components/dataList/dataList.widget.tsx","../src/components/lastTrades/lastTrades.ui.tsx","../src/components/lastTrades/lastTrades.script.tsx","../src/components/lastTrades/lastTrades.widget.tsx","../src/components/assetView/assetView.ui.tsx","../src/components/assetView/assetView.script.tsx","../src/components/assetView/assetView.widget.tsx","../src/components/orderBook/orderBook.ui.tsx","../src/components/orderBook/desktop/index.desktop.tsx","../src/components/orderBook/desktop/listBox.desktop.tsx","../src/components/orderBook/desktop/cell.desktop.tsx","../src/components/orderBook/orderContext.tsx","../src/components/orderBook/cellBar.tsx","../src/components/orderBook/desktop/bids.desktop.tsx","../src/components/orderBook/desktop/asks.desktop.tsx","../src/components/orderBook/desktop/markPrice.desktop.tsx","../src/components/orderBook/desktop/header.desktop.tsx","../src/components/orderBook/desktop/depthSelect.desktop.tsx","../src/components/orderBook/mWeb/header.tsx","../src/components/orderBook/mWeb/cell.tsx","../src/components/orderBook/mWeb/listBox.tsx","../src/components/orderBook/mWeb/bids.tsx","../src/components/orderBook/mWeb/asks.tsx","../src/components/orderBook/mWeb/markPrice.tsx","../src/components/orderBook/mWeb/depthSelect.tsx","../src/components/orderBook/mWeb/index.tsx","../src/components/orderBook/fundingRate/fundingRate.ui.tsx","../src/components/orderBook/fundingRate/fundingRate.script.tsx","../src/components/orderBook/fundingRate/fundingRate.widget.tsx","../src/components/orderBook/orderBook.script.tsx","../src/utils/utils.ts","../src/components/orderBook/orderBook.widget.tsx","../src/components/riskRate/riskRate.ui.tsx","../src/components/riskRate/riskRate.script.tsx","../src/components/riskRate/riskRate.widget.tsx","../src/components/orderBookAndTrades/orderBookAndTrades.ui.tsx","../src/components/orderBookAndTrades/orderBookAndTrades.script.tsx","../src/components/orderBookAndTrades/orderBookAndTrades.widget.tsx","../src/pages/tradingV2.ui.tsx","../src/provider/context.tsx","../src/pages/tradingV2.script.tsx","../src/pages/tradingV2.widget.tsx","../src/pages/tradingV2.page.tsx"],"names":["Layout","TradingPage","TradingPageProvider","jsx","Header","Content","MobileTradingPage","DesktopTradingPage","Trading","props","useAppContext","TradingWidget","wrongNetwork","Divider","Flex","TabPanel","Tabs","useLocalStorage","useDataListScript","current","config","unPnlPriceBasis","setUnPnlPriceBasic","pnlNotionalDecimalPrecision","setPnlNotionalDecimalPrecision","showAllSymbol","setShowAllSymbol","PositionsWidget","OrderListWidget","TabType","OrderStatus","Statistic","Text","Decimal","jsxs","PositionHeader","usePositionStream","useDataTap","usePositionHeaderScript","symbol","calcMode","data","aggregated","unrealPnL","unrealPnlROI","notional","PositionHeaderWidget","state","useState","Button","Checkbox","DropdownMenuContent","DropdownMenuRoot","DropdownMenuTrigger","SettingFillIcon","Setting","open","setOpen","checked","DecimalPrecisionCheckbox","e","UnPnlPriceBasisCheckBox","value","onValueChange","RadioButton","sel","label","onCheckChange","SelIcon","UnselIcon","useSettingScript","SettingWidget","DataList","PositionsView","DataListWidget","Box","cn","ScrollArea","OrderSide","commifyOptional","LastTrades","List","Row","key","left","mid","right","classNames","item","index","useMarketTradeStream","useSymbolsInfo","useLastTradesScript","isLoading","base","quote","baseDp","quoteDp","LastTradesWidget","useMemo","ArrowDownShortIcon","EyeIcon","EyeCloseIcon","ChevronDownIcon","Tooltip","gradientTextVariants","AuthGuard","AccountStatusEnum","Collapsible","CollapsibleContent","useAccount","Fragment","useCurrentStatusText","TotalValue","totalValue","visible","onToggleVisibility","AssetValueList","freeCollateral","marginRatioVal","renderMMR","isConnected","optionsOpen","setOptionsOpen","prevOpen","AssetView","networkId","isFirstTimeDeposit","onDeposit","onWithdraw","toggleVisible","currentStatus","title","description","titleColor","useAccountInstance","useEventEmitter","useMediaQuery","useSettleSubscription","useWalletSubscription","useConfig","usePrivateQuery","useCollateral","useMarginRatio","MEDIA_TABLET","modal","toast","capitalizeString","useCallback","DepositAndWithdrawWithSheetId","DepositAndWithdrawWithDialogId","useFirstTimeDeposit","unavailable","getKeyMemo","now","ninetyDaysAgo","startTime","endTime","searchParams","depositHistoryData","useAssetViewScript","account","matches","marginRatio","mmr","openDepositAndWithdraw","viewName","result","ee","onSettle","res","setVisible","side","transStatus","msg","status","AssetViewWidget","useEffect","useRef","getPrecisionByNumber","createContext","useContext","OrderBookContext","useOrderBookContext","OrderBookProvider","mode","setMode","totalMode","setTotalMode","parseNumber","CellBar","direction","transform","x","DesktopOrderBookCell","cellHeight","showTotal","onItemClick","depth","pendingOrders","symbolInfo","currentHover","base_dp","quote_dp","width","dp","totalAmount","isPendingOrder","priceStr","TooltipContent","TooltipTrigger","TooltipRoot","TooltipArrow","DesktopListBox","type","findMaxItem","priceDp","maxQty","a","b","hoverIndex","setHoverIndex","Tip","isHover","calcHintInfo","totalInfo","hintInfo","content","contentDp","DesktopBids","countQty","max","DesktopAsks","len","ArrowUpShortIcon","DesktopMarkPrice","markPrice","lastPrice","asks","bids","MiddlePriceView","MarkPriceView","Spread","className","iconSize","prevLastPrice","middlePrice","FlagIcon","spread","bid1","ask1","dValue","DesktopHeader","Title","name","token","justifyEnd","Select","DesktopDepthSelect","options","d","Spinner","DesktopOrderBook","onDepthChange","divRef","setShowTotal","rangeInfo","resizeObserver","entries","entry","count","targetDiv","onModeChange","currency","qtyLabel","OrderBookCell","qty","ListBox","Bids","Asks","MarkPrice","onMarkPrice","Picker","DepthSelect","FundingRate","predFundingRate","countDown","useFundingRate","useFundingRateScript","FundingRateWidget","OrderBook","useOrderbookStream","useOrderStream","removeTrailingZeros","getBasicSymbolInfo","DEFAULT_CELL_HEIGHT","SPACE","useOrderBookScript","height","setCellHeight","level","setLevel","allDepths","usePendingOrderStream","cellsHeight","restSpace","selDepth","depths","isMWeb","price","OrderBookWidget","Pencil","LeverageWidgetId","RiskRate","riskRate","riskRateColor","currentLeverage","maxLeverage","isHigh","isMedium","isLow","isDefault","textColor","useLeverage","getRiskRateColor","useRiskRateScript","riskRateNumber","RiskRateWidget","Grid","OrderBookAndTrades","TwoColLayout","TabLayout","tab","useOrderBookAndTradesScript","containerSize","setContainerSize","setTab","containerRef","OrderBookAndTradesWidget","TradingviewWidget","TradingV2","TradingPageContext","useTradingPateContext","useTradingV2Script","TradingV2Widget","TradingPageV2"],"mappings":"AAAA,OACE,UAAAA,GACA,eAAAC,GACA,uBAAAC,OAEK,yBAoBe,cAAAC,MAAA,oBAjBtB,GAAM,CAAE,OAAAC,GAAQ,QAAAC,EAAQ,EAAIL,GAEtB,CAAE,OAAQM,GAAmB,QAASC,EAAmB,EAAIN,GAEtDO,GACXC,GAGEN,EAACD,GAAA,CACC,OAAQO,EAAM,OACd,eAAgBA,EAAM,eACtB,gBAAiBA,EAAM,gBACvB,aAAcA,EAAM,aACpB,SAAUA,EAAM,SAChB,cAAeA,EAAM,cACrB,aAAcA,EAAM,aAEpB,SAAAN,EAACH,GAAA,CAAO,OAAQG,EAACG,GAAA,CAAmB,GAAGG,EAAO,EAC5C,SAAAN,EAACH,GAAA,CAAO,MAAO,CAAE,cAAe,MAAO,EACrC,SAAAG,EAACE,GAAA,CACC,SAAAF,EAACI,GAAA,CAAoB,GAAGE,EAAO,EACjC,EACF,EACF,EACF,EC9BJ,OAAS,iBAAAC,OAAqB,6BAIrB,cAAAP,OAAA,oBAFF,IAAMQ,GAAiBF,GAA4B,CACxD,GAAM,CAAC,aAAAG,CAAY,EAAIF,GAAc,EACrC,OAAOP,GAACK,GAAA,CAAS,GAAGC,EAAO,aAAcG,EAAc,CACzD,ECAS,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C,IAAMsV,GAAiBhV,GAE1BN,GAACD,GAAA,CACC,OAAQO,EAAM,OACd,kBAAmBA,EAAM,kBACzB,eAAgBA,EAAM,eACtB,gBAAiBA,EAAM,gBACvB,iBAAkBA,EAAM,iBACxB,SAAUA,EAAM,SAEhB,SAAAN,GAACqV,GAAA,EAAgB,EACnB","sourcesContent":["import {\n Layout,\n TradingPage,\n TradingPageProvider,\n TooltipProvider,\n} from \"@orderly.network/react\";\nimport { TradingPageProps } from \"../types/types\";\n\nconst { Header, Content } = Layout;\n\nconst { mobile: MobileTradingPage, desktop: DesktopTradingPage } = TradingPage;\n\nexport const Trading = (\n props: TradingPageProps & { wrongNetwork: boolean }\n) => {\n return (\n <TradingPageProvider\n symbol={props.symbol}\n onSymbolChange={props.onSymbolChange}\n disableFeatures={props.disableFeatures}\n shareOptions={props.shareOptions}\n referral={props.referral}\n tradingReward={props.tradingReward}\n wrongNetwork={props.wrongNetwork}\n >\n <Layout mobile={<MobileTradingPage {...props} />}>\n <Layout style={{ paddingBottom: \"42px\" }}>\n <Content>\n <DesktopTradingPage {...props} />\n </Content>\n </Layout>\n </Layout>\n </TradingPageProvider>\n );\n};\n","import { TradingPageProps } from \"../types/types\";\nimport { Trading } from \"./trading.ui\";\nimport { useAppContext } from \"@orderly.network/react-app\";\n\nexport const TradingWidget = (props: TradingPageProps) => {\n const {wrongNetwork} = useAppContext();\n return <Trading {...props} wrongNetwork={wrongNetwork} />;\n};\n","import { TradingPageProps } from \"../types/types\";\nimport { TradingWidget } from \"./trading.widget\";\n\n\nexport const TradingPage = (\n props: TradingPageProps\n) => {\n return <TradingWidget {...props} />;\n};\n","export { TradingPage } from \"./pages/trading.page\";\nexport type { ShareOptions } from \"./types/types\";\n\nimport \"./style/style.css\";\nimport \"@orderly.network/react/dist/styles.css\";\n\nexport * from \"./components/dataList\";\nexport * from \"./components/lastTrades\";\nexport * from \"./components/assetView\";\nexport * from \"./components/orderBook\";\nexport * from \"./components/riskRate\";\nexport * from \"./components/orderBookAndTrades\";\nexport * from \"./pages\";\nexport * from \"./provider\";\n","import { FC } from \"react\";\nimport { Divider, Flex, TabPanel, Tabs, Text } from \"@orderly.network/ui\";\nimport { DataListState, DataListTabType } from \"./dataList.script\";\nimport { PositionsWidget } from \"@orderly.network/ui-positions\";\nimport { OrderListWidget, TabType } from \"@orderly.network/ui-orders\";\nimport { OrderStatus } from \"@orderly.network/types\";\nimport { PositionHeaderWidget } from \"./positionHeader\";\nimport { SettingWidget } from \"./setting\";\n\nexport const DataList: FC<DataListState> = (props) => {\n return (\n <Tabs\n defaultValue={props.current || DataListTabType.positions}\n variant=\"contained\"\n trailing={\n <SettingWidget\n pnlNotionalDecimalPrecision={props.pnlNotionalDecimalPrecision}\n setPnlNotionalDecimalPrecision={props.setPnlNotionalDecimalPrecision}\n unPnlPriceBasis={props.unPnlPriceBasis}\n setUnPnlPriceBasic={props.setUnPnlPriceBasic}\n showAllSymbol={props.showAllSymbol}\n setShowAllSymbol={props.setShowAllSymbol}\n />\n }\n >\n <TabPanel\n value={DataListTabType.positions}\n title={DataListTabType.positions}\n >\n <PositionsView {...props} />\n </TabPanel>\n <TabPanel value={DataListTabType.pending} title={DataListTabType.pending}>\n <OrderListWidget\n type={TabType.pending}\n ordersStatus={OrderStatus.INCOMPLETE}\n />\n </TabPanel>\n <TabPanel value={DataListTabType.tp_sl} title={DataListTabType.tp_sl}>\n <OrderListWidget\n type={TabType.tp_sl}\n ordersStatus={OrderStatus.INCOMPLETE}\n />\n </TabPanel>\n <TabPanel value={DataListTabType.filled} title={DataListTabType.filled}>\n <OrderListWidget\n type={TabType.filled}\n ordersStatus={OrderStatus.FILLED}\n />\n </TabPanel>\n <TabPanel\n value={DataListTabType.orderHistory}\n title={DataListTabType.orderHistory}\n >\n <OrderListWidget type={TabType.orderHistory} />\n </TabPanel>\n </Tabs>\n );\n};\n\nconst PositionsView: FC<DataListState> = (props) => {\n return (\n <Flex direction={\"column\"}>\n <PositionHeaderWidget\n pnlNotionalDecimalPrecision={props.pnlNotionalDecimalPrecision}\n symbol={props.config?.symbol}\n unPnlPriceBasis={props.unPnlPriceBasis}\n />\n <Divider className=\"oui-w-full\" />\n <PositionsWidget {...props.config} pnlNotionalDecimalPrecision={props.pnlNotionalDecimalPrecision} />\n </Flex>\n );\n};\n","import { useLocalStorage } from \"@orderly.network/hooks\";\nimport { PositionsProps } from \"@orderly.network/ui-positions\";\nimport { useEffect, useState } from \"react\";\n\nexport enum DataListTabType {\n positions = \"Positions\",\n pending = \"Pending\",\n tp_sl = \"TP/SL\",\n filled = \"Filled\",\n orderHistory = \"Order history\",\n}\n\nexport const useDataListScript = (props: {\n current?: DataListTabType;\n config: PositionsProps & {\n symbol?: string;\n };\n }) => {\n const { current, config } = props;\n const [unPnlPriceBasis, setUnPnlPriceBasic] = useLocalStorage('unPnlPriceBasis', 'markPrice');\n const [pnlNotionalDecimalPrecision, setPnlNotionalDecimalPrecision] = useLocalStorage('pnlNotionalDecimalPrecision', 2);\n const [showAllSymbol, setShowAllSymbol] = useLocalStorage('showAllSymbol', true);\n \n return {\n current,\n config,\n unPnlPriceBasis,\n setUnPnlPriceBasic,\n pnlNotionalDecimalPrecision,\n setPnlNotionalDecimalPrecision,\n showAllSymbol,\n setShowAllSymbol,\n };\n};\n\nexport type DataListState = ReturnType<typeof useDataListScript>;\n","import { FC } from \"react\";\nimport { Flex, Statistic, Text } from \"@orderly.network/ui\";\nimport { PositionHeaderState } from \"./positionHeader.script\";\nimport { Decimal } from \"@orderly.network/utils\";\n\nexport const PositionHeader: FC<PositionHeaderState> = (props) => {\n return (\n <Flex px={3} py={2} gap={6} width={\"100%\"} justify={\"start\"}>\n <Statistic label=\"Unreal. PnL\">\n <Flex>\n <Text.numeral\n coloring\n dp={props.pnlNotionalDecimalPrecision}\n rm={Decimal.ROUND_DOWN}\n >\n {props.unrealPnL}\n </Text.numeral>\n {props.unrealPnlROI && (\n <Text.numeral\n coloring\n prefix=\"(\"\n suffix=\")\"\n rule=\"percentages\"\n dp={props.pnlNotionalDecimalPrecision}\n rm={Decimal.ROUND_DOWN}\n >\n {props.unrealPnlROI}\n </Text.numeral>\n )}\n </Flex>\n </Statistic>\n <Statistic label=\"Notional\">\n <Text.numeral\n dp={props.pnlNotionalDecimalPrecision}\n rm={Decimal.ROUND_DOWN}\n >\n {props.notional}\n </Text.numeral>\n </Statistic>\n </Flex>\n );\n};\n","import { usePositionStream } from \"@orderly.network/hooks\";\nimport { useDataTap } from \"@orderly.network/react-app\";\nimport { useMemo } from \"react\";\n\nexport const usePositionHeaderScript = (props: {\n pnlNotionalDecimalPrecision?: number;\n unPnlPriceBasis: \"markPrice\" | \"lastPrice\";\n symbol?: string;\n}) => {\n const { pnlNotionalDecimalPrecision, unPnlPriceBasis, symbol } = props;\n const calcMode = unPnlPriceBasis;\n\n const [data] = usePositionStream(symbol, {\n calcMode,\n });\n const aggregated = useDataTap(data.aggregated);\n const unrealPnL = aggregated?.unrealPnL;\n const unrealPnlROI = aggregated?.unrealPnlROI;\n const notional = aggregated?.notional;\n return {\n pnlNotionalDecimalPrecision,\n unrealPnL,\n unrealPnlROI,\n notional,\n };\n};\n\nexport type PositionHeaderState = ReturnType<typeof usePositionHeaderScript>;\n","import { usePositionHeaderScript } from \"./positionHeader.script\";\nimport { PositionHeader } from \"./positionHeader.ui\";\n\nexport const PositionHeaderWidget = (props: {\n pnlNotionalDecimalPrecision?: number;\n unPnlPriceBasis: \"markPrice\" | \"lastPrice\";\n symbol?: string;\n}) => {\n const state = usePositionHeaderScript(props);\n return <PositionHeader {...state} />;\n};\n","import { FC, useCallback, useState } from \"react\";\nimport {\n Button,\n Checkbox,\n Divider,\n DropdownMenuContent,\n DropdownMenuRoot,\n DropdownMenuTrigger,\n Flex,\n SettingFillIcon,\n Text,\n} from \"@orderly.network/ui\";\nimport { SettingState } from \"./setting.script\";\n\nexport const Setting: FC<SettingState> = (props) => {\n const [open, setOpen] = useState(false);\n return (\n <Flex gap={0}>\n <Flex gap={1}>\n <Checkbox\n color=\"white\"\n checked={props.showAllSymbol}\n onCheckedChange={(checked: boolean) => {\n props.setShowAllSymbol(checked);\n }}\n />\n <Text size=\"xs\" intensity={54}>\n Show all instruments\n </Text>\n </Flex>\n <Button\n size=\"xs\"\n type=\"button\"\n variant=\"contained\"\n className=\"oui-bg-transparent hover:oui-bg-transparent\"\n >\n <DropdownMenuRoot open={open} onOpenChange={setOpen}>\n <DropdownMenuTrigger>\n <SettingFillIcon size={16} color=\"white\" />\n </DropdownMenuTrigger>\n <DropdownMenuContent className=\"oui-p-2\" alignOffset={2} align=\"end\">\n <div className=\"oui-flex oui-flex-col oui-text-3xs\">\n <Text className=\"oui-text-xs oui-pb-3\">Portfolio Settings</Text>\n <Divider />\n <Text className=\"oui-pb-3 oui-text-base-contrast-54 oui-mt-2\">\n Decimal Precision for PnL & Notional\n </Text>\n <DecimalPrecisionCheckbox\n value={props.pnlNotionalDecimalPrecision}\n onValueChange={(e) => {\n props.setPnlNotionalDecimalPrecision(e);\n setOpen(false);\n }}\n />\n <Divider className=\"oui-my-3\" />\n <Text className=\"oui-pb-3 oui-text-base-contrast-54 oui-mt-2\">\n Unrealized PnL Price Basis\n </Text>\n <UnPnlPriceBasisCheckBox\n value={props.unPnlPriceBasis}\n onValueChange={(e) => {\n props.setUnPnlPriceBasic(e);\n setOpen(false);\n }}\n />\n </div>\n </DropdownMenuContent>\n </DropdownMenuRoot>\n </Button>\n </Flex>\n );\n};\n\nconst UnPnlPriceBasisCheckBox = (props: {\n value: string;\n onValueChange: (value: string) => void;\n}) => {\n const { value, onValueChange } = props;\n // \"markPrice\" | \"lastPrice\"\n return (\n <Flex gap={2}>\n <RadioButton\n sel={value === \"markPrice\"}\n label={\"Mark price\"}\n value={\"markPrice\"}\n onCheckChange={onValueChange}\n />\n <RadioButton\n sel={value === \"lastPrice\"}\n label={\"Last price\"}\n value={\"lastPrice\"}\n onCheckChange={onValueChange}\n />\n </Flex>\n );\n};\n\nconst DecimalPrecisionCheckbox = (props: {\n value: number;\n onValueChange: (value: number) => void;\n}) => {\n const { value, onValueChange } = props;\n return (\n <Flex gap={2}>\n <RadioButton\n sel={value === 0}\n label={1}\n value={0}\n onCheckChange={onValueChange}\n />\n <RadioButton\n sel={value === 1}\n label={0.1}\n value={1}\n onCheckChange={onValueChange}\n />\n <RadioButton\n sel={value === 2}\n label={0.01}\n value={2}\n onCheckChange={onValueChange}\n />\n </Flex>\n );\n};\n\n// const InnerCheckbox = (props: {\n// sel: boolean;\n// label: any;\n// value: any;\n// onCheckChange: (value: any) => void;\n// }) => {\n// const { sel, label, value, onCheckChange } = props;\n// return (\n// <Flex\n// onClick={(e) => {\n// onCheckChange(value);\n// e.stopPropagation();\n// }}\n// gap={1}\n// >\n// <Checkbox color=\"white\" checked={sel} />\n// <Text size=\"xs\" intensity={sel ? 98 : 54}>\n// {`${label}`}\n// </Text>\n// </Flex>\n// );\n// };\n\nconst RadioButton = (props: {\n sel: boolean;\n label: any;\n value: any;\n onCheckChange: (value: any) => void;\n }) => {\n const { sel, label, value, onCheckChange } = props;\n return (\n <Flex\n onClick={(e) => {\n onCheckChange(value);\n e.stopPropagation();\n }}\n gap={1}\n className=\"oui-cursor-pointer\"\n >\n {sel ? <SelIcon /> : <UnselIcon />}\n <Text size=\"xs\" intensity={sel ? 98 : 54}>{label}</Text>\n </Flex>\n );\n };\n \n const SelIcon = () => {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"oui-fill-white\"\n >\n <path\n d=\"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667\"\n fill=\"#fff\"\n fillOpacity=\".36\"\n />\n <circle cx=\"8\" cy=\"8\" r=\"3.333\" />\n </svg>\n );\n };\n \n const UnselIcon = () => {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667\"\n fill=\"#fff\"\n fillOpacity=\".54\"\n />\n </svg>\n );\n };\n","import { useLocalStorage } from \"@orderly.network/hooks\";\n\nexport const useSettingScript = (props: {\n pnlNotionalDecimalPrecision: any;\n setPnlNotionalDecimalPrecision: (value: number) => void;\n unPnlPriceBasis: any;\n setUnPnlPriceBasic: (value: string) => void;\n showAllSymbol: any;\n setShowAllSymbol: (value: boolean) => void;\n}) => {\n const {\n pnlNotionalDecimalPrecision,\n setPnlNotionalDecimalPrecision,\n unPnlPriceBasis,\n setUnPnlPriceBasic,\n showAllSymbol,\n setShowAllSymbol,\n } = props;\n return {\n pnlNotionalDecimalPrecision,\n setPnlNotionalDecimalPrecision,\n unPnlPriceBasis,\n setUnPnlPriceBasic,\n showAllSymbol,\n setShowAllSymbol,\n };\n};\n\nexport type SettingState = ReturnType<typeof useSettingScript>;\n","import { useSettingScript } from \"./setting.script\";\nimport { Setting } from \"./setting.ui\";\n\nexport const SettingWidget = (props: {\n pnlNotionalDecimalPrecision: any;\n setPnlNotionalDecimalPrecision: (value: number) => void;\n unPnlPriceBasis: any;\n setUnPnlPriceBasic: (value: string) => void;\n showAllSymbol: any;\n setShowAllSymbol: (value: boolean) => void;\n }) => {\n const state = useSettingScript(props);\n return <Setting {...state} />;\n};\n","import { PositionsProps } from \"@orderly.network/ui-positions\";\nimport { DataListTabType, useDataListScript } from \"./dataList.script\";\nimport { DataList } from \"./dataList.ui\";\n\nexport const DataListWidget = (props: {\n current?: DataListTabType;\n config: Partial<Omit<PositionsProps, \"pnlNotionalDecimalPrecision\">>;\n}) => {\n const state = useDataListScript(props);\n return <DataList {...state} />;\n};\n","import { FC, ReactNode } from \"react\";\nimport { Box, cn, Flex, ScrollArea, Text } from \"@orderly.network/ui\";\nimport { LastTradesState } from \"./lastTrades.script\";\nimport { API, OrderSide } from \"@orderly.network/types\";\nimport { commifyOptional } from \"@orderly.network/utils\";\n\nexport const LastTrades: FC<\n LastTradesState & {\n className?: string;\n style?: React.CSSProperties;\n }\n> = (props) => {\n return (\n <Flex\n direction={\"column\"}\n itemAlign={\"start\"}\n className={cn(\"oui-font-semibold\", props.className)}\n width={\"100%\"}\n height={\"100%\"}\n style={props.style}\n >\n <Header base={props.base} quote={props.quote} />\n <List\n data={props.data}\n isLoading={props.isLoading}\n baseDp={props.baseDp}\n quoteDp={props.quoteDp}\n />\n </Flex>\n );\n};\n\nconst Row = (props: {\n key?: React.Key | null;\n classNames?: {\n root?: string;\n left?: string;\n mid?: string;\n right?: string;\n };\n left: ReactNode | string;\n mid: ReactNode | string;\n right: ReactNode | string;\n}) => {\n const { key, left, mid, right, classNames } = props;\n return (\n <Flex\n key={key}\n height={20}\n gap={2}\n width={\"100%\"}\n className={cn(\"oui-text-xs oui-tabular-nums\", classNames?.root)}\n >\n <Box className={cn(\"oui-flex-1\", classNames?.left)}>{left}</Box>\n <Box className={cn(\"oui-flex-1\", classNames?.mid)}>{mid}</Box>\n <Box className={cn(\"oui-flex-1 oui-text-right\", classNames?.right)}>\n {right}\n </Box>\n </Flex>\n );\n};\n\nconst Header = (props: { base: string; quote: string }) => {\n return (\n <Row\n left=\"Time\"\n mid={`Price(${props.quote})`}\n right={`Qty(${props.base})`}\n classNames={{ root: \"oui-text-base-contrast-54 oui-h-[32px]\" }}\n />\n );\n};\n\nconst List = (props: {\n data?: any[];\n isLoading?: boolean;\n baseDp: number;\n quoteDp: number;\n}) => {\n return (\n <ScrollArea className=\"oui-w-full oui-h-full\">\n {props.data?.map((item, index) => {\n return (\n <Row\n key={index}\n left={\n <Text.formatted rule={\"date\"} formatString=\"HH:mm:ss\">\n {item?.ts}\n </Text.formatted>\n }\n mid={commifyOptional(item?.price, { fix: props.quoteDp })}\n right={commifyOptional(item?.size, { fix: props.baseDp })}\n classNames={{\n left: \"oui-text-base-contrast-80\",\n right:\n item.side === OrderSide.BUY\n ? \"oui-text-trade-profit\"\n : \"oui-text-trade-loss\",\n mid:\n item.side === OrderSide.BUY\n ? \"oui-text-trade-profit\"\n : \"oui-text-trade-loss\",\n }}\n />\n );\n })}\n </ScrollArea>\n );\n};\n","import { useMarketTradeStream, useSymbolsInfo } from \"@orderly.network/hooks\";\n\nexport const useLastTradesScript = (symbol: string) => {\n const { data, isLoading } = useMarketTradeStream(symbol);\n // const { quote, quote_dp, base, base_dp } = useContext(SymbolContext);\n const config = useSymbolsInfo()?.[symbol];\n const base = config?.(\"base\");\n const quote = config?.(\"quote\");\n const baseDp = config?.(\"base_dp\");\n const quoteDp = config?.(\"quote_dp\");\n// console.log(\"base, quote\", base, quote, \"baseDp, quoteDp\", baseDp, quoteDp);\n\n return {\n base,\n quote,\n data,\n isLoading,\n baseDp,\n quoteDp,\n };\n};\n\nexport type LastTradesState = ReturnType<typeof useLastTradesScript>;\n","import { useLastTradesScript } from \"./lastTrades.script\";\nimport { LastTrades } from \"./lastTrades.ui\";\n\nexport const LastTradesWidget = (props: {\n symbol: string;\n className?: string;\n style?: React.CSSProperties;\n}) => {\n const state = useLastTradesScript(props.symbol);\n return <LastTrades {...state} className={props.className} style={props.style} />;\n};\n","import React, { FC, useMemo, useState } from \"react\";\nimport {\n Flex,\n Text,\n Box,\n Button,\n ArrowDownShortIcon,\n EyeIcon,\n EyeCloseIcon,\n ChevronDownIcon,\n Tooltip,\n Divider,\n gradientTextVariants,\n} from \"@orderly.network/ui\";\nimport { AssetViewState } from \"./assetView.script\";\nimport { AuthGuard } from \"@orderly.network/ui-connector\";\nimport { AccountStatusEnum } from \"@orderly.network/types\";\nimport { cn, Collapsible, CollapsibleContent } from \"@orderly.network/react\";\nimport { useAccount, useLocalStorage } from \"@orderly.network/hooks\";\nimport { useAppContext } from \"@orderly.network/react-app\";\n\ninterface StatusInfo {\n title: string;\n description: string;\n titleColor?: any;\n}\n\nexport const useCurrentStatusText = (): StatusInfo => {\n const { state } = useAccount();\n const { wrongNetwork } = useAppContext();\n\n /**\n * TODO:\n * script文件不应该包括UI显示的具体数据,建议移动到ui文件中\n * 处理完成之后,请删掉 TODO\n */\n const currentStatus = useMemo(() => {\n if (wrongNetwork) {\n return {\n title: \"Wrong Network\",\n description: \"Please switch to a supported network to continue.\",\n titleColor: \"warning\",\n };\n }\n\n switch (state.status) {\n case AccountStatusEnum.NotConnected:\n return {\n title: \"Connect wallet\",\n description: \"Please connect your wallet before starting to trade.\",\n };\n case AccountStatusEnum.NotSignedIn:\n return {\n title: \"Sign in\",\n description: \"Please sign in before starting to trade.\",\n titleColor: \"primaryLight\",\n };\n case AccountStatusEnum.DisabledTrading:\n return {\n title: \"Enable trading\",\n description: \"Enable trading before starting to trade.\",\n titleColor: \"primaryLight\",\n };\n default:\n return {\n title: \"\",\n description: \"\",\n };\n }\n }, [state.status, wrongNetwork]);\n\n return currentStatus;\n};\n\nconst TotalValue: FC<{\n totalValue: number | null;\n visible?: boolean;\n onToggleVisibility?: () => void;\n}> = ({ totalValue = 0, visible = true, onToggleVisibility }) => {\n return (\n <Flex\n direction={\"column\"}\n gap={1}\n className=\"oui-text-2xs\"\n itemAlign={\"center\"}\n >\n <Text.numeral\n visible={visible}\n weight=\"bold\"\n size=\"2xl\"\n className={gradientTextVariants({ color: \"brand\" })}\n as=\"div\"\n padding={false}\n >\n {totalValue ?? \"--\"}\n </Text.numeral>\n\n <Flex gap={1} itemAlign={\"center\"}>\n <Text size=\"2xs\" color=\"neutral\" weight=\"semibold\">\n My Assets (USDC)\n </Text>\n\n <button onClick={() => onToggleVisibility?.()}>\n {visible ? (\n <EyeIcon size={18} className=\"oui-text-base-contrast-54\" />\n ) : (\n <EyeCloseIcon size={18} className=\"oui-text-base-contrast-54\" />\n )}\n </button>\n </Flex>\n </Flex>\n );\n};\n\nconst AssetValueList: FC<{\n visible?: boolean;\n freeCollateral: number | null;\n marginRatioVal: number;\n renderMMR: string;\n isConnected: boolean;\n}> = ({\n visible = true,\n freeCollateral,\n marginRatioVal,\n renderMMR,\n isConnected,\n}) => {\n const [optionsOpen, setOptionsOpen] = useLocalStorage(\n \"orderly_entry_asset_list_open\",\n false\n );\n const [open, setOpen] = useState<boolean>(optionsOpen);\n\n return (\n <Box>\n <Flex\n justify=\"center\"\n gap={1}\n itemAlign={\"center\"}\n className=\"oui-cursor-pointer\"\n onClick={() => {\n setOpen((prevOpen) => !prevOpen);\n setOptionsOpen(!open);\n }}\n >\n <Divider className=\"oui-flex-1\" />\n <ChevronDownIcon\n size={18}\n color=\"white\"\n className={cn(\"oui-transition-transform\", open && \"oui-rotate-180\")}\n />\n <Divider className=\"oui-flex-1\" />\n </Flex>\n\n <Collapsible open={open}>\n <CollapsibleContent>\n <Box className=\"oui-space-y-1.5\">\n <Flex justify=\"between\">\n <Tooltip\n content={\n (\n <div>\n <span>Free collateral for placing new orders.</span>\n <Divider className=\"oui-py-2 oui-border-white/10\" />\n <span>\n Free collateral = Total balance + Total unsettlement PnL\n - Total position initial margin\n </span>\n </div>\n ) as any\n }\n >\n <Text\n size=\"2xs\"\n color=\"neutral\"\n weight=\"semibold\"\n className=\"oui-cursor-pointer\"\n >\n Free collateral\n </Text>\n </Tooltip>\n <Text.numeral\n visible={visible}\n size=\"2xs\"\n unit=\"USDC\"\n unitClassName=\"oui-text-base-contrast-36\"\n as=\"div\"\n padding={false}\n >\n {freeCollateral ?? \"--\"}\n </Text.numeral>\n </Flex>\n\n <Flex justify=\"between\">\n <Tooltip\n content={\n (\n <div>\n <span>\n Your actual Leverage of the whole account / Your max\n Leverage of the whole account\n </span>\n <Divider className=\"oui-py-2 oui-border-white/10\" />\n <span>\n Margin ratio = Total collateral / Total position\n notional\n </span>\n </div>\n ) as any\n }\n >\n <Text\n size=\"2xs\"\n color=\"neutral\"\n weight=\"semibold\"\n className=\"oui-cursor-pointer\"\n >\n Margin ratio\n </Text>\n </Tooltip>\n {isConnected ? (\n <Text.numeral\n size=\"2xs\"\n unitClassName=\"oui-text-base-contrast-36\"\n as=\"div\"\n rule=\"percentages\"\n padding={false}\n >\n {marginRatioVal}\n </Text.numeral>\n ) : (\n <Text className=\"oui-text-base-contrast-36\">--</Text>\n )}\n </Flex>\n\n <Flex justify=\"between\">\n <Tooltip\n content={\n (\n <div>\n <span>Maintenance margin ratio.</span>\n <Divider className=\"oui-py-2 oui-border-white/10\" />\n <span>Maintenance margin ratio = ...</span>\n </div>\n ) as any\n }\n >\n <Text\n size=\"2xs\"\n color=\"neutral\"\n weight=\"semibold\"\n className=\"oui-cursor-pointer\"\n >\n Maintenance margin ratio\n </Text>\n </Tooltip>\n {renderMMR ? (\n <Text.numeral\n size=\"2xs\"\n suffix=\"%\"\n unitClassName=\"oui-text-base-contrast-36\"\n as=\"div\"\n padding={false}\n >\n {renderMMR}\n </Text.numeral>\n ) : (\n <Text className=\"oui-text-base-contrast-36\">--</Text>\n )}\n </Flex>\n </Box>\n </CollapsibleContent>\n </Collapsible>\n </Box>\n );\n};\n\nexport const AssetView: FC<AssetViewState> = ({\n networkId,\n isFirstTimeDeposit,\n totalValue,\n onDeposit,\n onWithdraw,\n toggleVisible,\n visible,\n freeCollateral,\n marginRatioVal,\n renderMMR,\n isConnected,\n}) => {\n const currentStatus = useCurrentStatusText();\n const { title, description } = currentStatus;\n const titleColor = currentStatus.titleColor ?? \"\";\n\n return (\n <Box>\n {title && description ? (\n <Flex direction=\"column\" gap={1} className=\"oui-mb-[32px]\">\n {titleColor ? (\n <Text size=\"lg\" weight=\"bold\" color={titleColor}>\n {title}\n </Text>\n ) : (\n <Text.gradient size=\"lg\" weight=\"bold\" color={\"brand\"}>\n {title}\n </Text.gradient>\n )}\n\n <Text size=\"2xs\" color=\"neutral\" weight=\"semibold\">\n {description}\n </Text>\n </Flex>\n ) : null}\n <AuthGuard\n networkId={networkId}\n status={AccountStatusEnum.EnableTrading}\n buttonProps={{ size: \"md\", fullWidth: true }}\n >\n {isFirstTimeDeposit ? (\n <>\n <Box>\n <Flex direction=\"column\" gap={1} className=\"oui-mb-[32px]\">\n <Text.gradient size=\"lg\" weight=\"bold\" color={\"brand\"}>\n Deposit to start trade\n </Text.gradient>\n <Text size=\"2xs\" color=\"neutral\" weight=\"semibold\">\n You can deposit assets from various networks\n </Text>\n </Flex>\n </Box>\n <Button fullWidth size=\"md\" onClick={onDeposit}>\n <ArrowDownShortIcon color=\"white\" opacity={1} />\n <Text>Deposit</Text>\n </Button>\n </>\n ) : (\n <Box className=\"oui-space-y-4\">\n <TotalValue\n totalValue={totalValue}\n visible={visible}\n onToggleVisibility={toggleVisible}\n />\n <AssetValueList\n visible={visible}\n freeCollateral={freeCollateral}\n marginRatioVal={marginRatioVal}\n renderMMR={renderMMR}\n isConnected={isConnected}\n />\n <Flex gap={3} itemAlign={\"center\"}>\n <Button\n fullWidth\n color=\"secondary\"\n size=\"md\"\n onClick={onWithdraw}\n >\n <ArrowDownShortIcon\n color=\"white\"\n opacity={1}\n className=\"oui-rotate-180\"\n />\n <Text>Withdraw</Text>\n </Button>\n <Button fullWidth size=\"md\" onClick={onDeposit}>\n <ArrowDownShortIcon color=\"white\" opacity={1} />\n <Text>Deposit</Text>\n </Button>\n </Flex>\n </Box>\n )}\n </AuthGuard>\n </Box>\n );\n};\n","import {\n useAccountInstance,\n useEventEmitter,\n useLocalStorage,\n useMediaQuery,\n useSettleSubscription,\n useWalletSubscription,\n useAccount,\n useConfig,\n usePrivateQuery,\n useCollateral,\n useMarginRatio,\n} from \"@orderly.network/hooks\";\nimport {\n MEDIA_TABLET,\n AccountStatusEnum,\n NetworkId,\n API,\n} from \"@orderly.network/types\";\nimport { modal, toast } from \"@orderly.network/ui\";\nimport { capitalizeString } from \"@orderly.network/utils\";\nimport { useCallback, useMemo } from \"react\";\nimport {\n DepositAndWithdrawWithSheetId,\n DepositAndWithdrawWithDialogId,\n} from \"@orderly.network/ui-transfer\";\nimport { useAppContext } from \"@orderly.network/react-app\";\nimport { Decimal } from \"@orderly.network/utils\";\n\nconst useFirstTimeDeposit = () => {\n const { state } = useAccount();\n const { wrongNetwork } = useAppContext();\n const { totalValue } = useCollateral({\n dp: 2,\n });\n const unavailable =\n wrongNetwork || state.status < AccountStatusEnum.EnableTrading;\n const getKeyMemo = useMemo(() => {\n const now = new Date();\n const ninetyDaysAgo = new Date();\n ninetyDaysAgo.setDate(now.getDate() - 90);\n\n const startTime = ninetyDaysAgo.getTime();\n const endTime = now.getTime();\n\n const searchParams = new URLSearchParams();\n\n searchParams.set(\"page\", \"1\");\n searchParams.set(\"size\", \"5\");\n searchParams.set(\"side\", \"DEPOSIT\");\n searchParams.set(\"status\", \"COMPLETED\");\n searchParams.set(\"startTime\", startTime.toString());\n searchParams.set(\"endTime\", endTime.toString());\n\n return `/v1/asset/history?${searchParams.toString()}`;\n }, []);\n\n const { data: depositHistoryData } = usePrivateQuery<API.AssetHistory>(\n getKeyMemo,\n {\n formatter: (data) => data,\n }\n );\n\n return {\n isFirstTimeDeposit:\n !unavailable && totalValue === 0 && depositHistoryData?.meta?.total === 0,\n totalValue,\n };\n};\n\nexport const useAssetViewScript = () => {\n const account = useAccountInstance();\n const matches = useMediaQuery(MEDIA_TABLET);\n\n const { isFirstTimeDeposit, totalValue } = useFirstTimeDeposit();\n\n const networkId = useConfig(\"networkId\") as NetworkId;\n const { state } = useAccount();\n const { freeCollateral } = useCollateral({\n dp: 2,\n });\n const { marginRatio, mmr } = useMarginRatio();\n const isConnected = state.status >= AccountStatusEnum.Connected;\n const marginRatioVal = marginRatio === 0 ? 10 : Math.min(marginRatio, 10);\n\n const renderMMR = useMemo(() => {\n if (!mmr) {\n return \"--\";\n }\n const bigMMR = new Decimal(mmr);\n return bigMMR.mul(100).todp(2, 0).toFixed(2);\n }, [mmr]);\n\n const openDepositAndWithdraw = useCallback(\n async (viewName: \"deposit\" | \"withdraw\") => {\n let result;\n if (matches) {\n result = await modal.show(DepositAndWithdrawWithSheetId, {\n activeTab: viewName,\n });\n } else {\n result = await modal.show(DepositAndWithdrawWithDialogId, {\n activeTab: viewName,\n });\n }\n\n return result;\n },\n [matches]\n );\n\n const onDeposit = useCallback(async () => {\n return openDepositAndWithdraw(\"deposit\");\n }, [matches]);\n\n const ee = useEventEmitter();\n\n const onWithdraw = useCallback(async () => {\n return openDepositAndWithdraw(\"withdraw\");\n }, [matches]);\n\n const onSettle = useCallback(async () => {\n return account\n .settle()\n .catch((e) => {\n if (e.code === -1104) {\n toast.error(\n \"Settlement is only allowed once every 10 minutes. Please try again later.\"\n );\n return Promise.reject(e);\n }\n })\n .then((res) => {\n toast.success(\"Settlement requested\");\n return Promise.resolve(res);\n });\n }, [account]);\n\n const [visible, setVisible] = useLocalStorage<boolean>(\n \"orderly_assets_visible\",\n true\n );\n\n const toggleVisible = useCallback(() => {\n // @ts-ignore\n setVisible((visible: boolean) => {\n return !visible;\n });\n }, [visible]);\n\n useWalletSubscription({\n onMessage: (data: any) => {\n const { side, transStatus } = data;\n\n if (transStatus === \"COMPLETED\") {\n let msg = `${capitalizeString(side)} completed`;\n toast.success(msg);\n } else if (transStatus === \"FAILED\") {\n let msg = `${capitalizeString(side)} failed`;\n toast.error(msg);\n }\n\n ee.emit(\"wallet:changed\", data);\n },\n });\n\n useSettleSubscription({\n onMessage: (data: any) => {\n const { status } = data;\n\n switch (status) {\n case \"COMPLETED\":\n toast.success(\"Settlement completed\");\n break;\n case \"FAILED\":\n toast.error(\"Settlement failed\");\n break;\n default:\n break;\n }\n },\n });\n\n return {\n onDeposit,\n onWithdraw,\n onSettle,\n visible,\n toggleVisible,\n networkId,\n isFirstTimeDeposit,\n totalValue,\n status: state.status,\n freeCollateral,\n marginRatioVal,\n renderMMR,\n isConnected,\n };\n};\n\nexport type AssetViewState = ReturnType<typeof useAssetViewScript>;\n","import { useAssetViewScript } from \"./assetView.script\";\nimport { AssetView } from \"./assetView.ui\";\n\nexport const AssetViewWidget = () => {\n const state = useAssetViewScript();\n return (<AssetView {...state} />);\n};\n","import { FC } from \"react\";\nimport { Box, Flex, Text } from \"@orderly.network/ui\";\nimport { OrderBookState } from \"./orderBook.script\";\nimport { DesktopOrderBook } from \"./desktop/index.desktop\";\nimport { OrderBook as MWebOrderBook } from \"./mWeb/index\";\n\nexport const OrderBook: FC<\n OrderBookState & {\n className?: string;\n }\n> = (props) => {\n return (\n <Box className=\"oui-font-semibold\" width={\"100%\"} height={\"100%\"}>\n {props.isMWeb ? (\n <MWebOrderBook\n level={props.level}\n asks={props.asks!}\n bids={props.bids!}\n markPrice={props.markPrice!}\n lastPrice={props.lastPrice!}\n depths={props.depths}\n activeDepth={props.selDepth}\n base={props.base}\n quote={props.quote}\n isLoading={props.isLoading}\n onItemClick={props.onItemClick}\n cellHeight={props.cellHeight}\n onDepthChange={props.onDepthChange}\n className={props.className}\n symbolInfo={props.symbolInfo}\n />\n ) : (\n <DesktopOrderBook\n level={props.level}\n asks={props.asks!}\n bids={props.bids!}\n markPrice={props.markPrice!}\n lastPrice={props.lastPrice!}\n depths={props.depths}\n activeDepth={props.selDepth}\n base={props.base}\n quote={props.quote}\n isLoading={props.isLoading}\n onItemClick={props.onItemClick}\n cellHeight={props.cellHeight}\n onDepthChange={props.onDepthChange}\n className={props.className}\n pendingOrders={props.pendingOrders}\n symbolInfo={props.symbolInfo}\n />\n )}\n </Box>\n );\n};\n","import React, { FC, useCallback, useEffect, useRef, useState } from \"react\";\nimport { DesktopBids } from \"./bids.desktop\";\nimport { DesktopAsks } from \"./asks.desktop\";\nimport { DesktopMarkPrice } from \"./markPrice.desktop\";\nimport { DesktopHeader } from \"./header.desktop\";\nimport { DesktopDepthSelect } from \"./depthSelect.desktop\";\nimport { OrderBookProvider } from \"../orderContext\";\nimport { cn, Spinner } from \"@orderly.network/ui\";\nimport { BasicSymbolInfo } from \"../../../types/types\";\n\nexport interface DesktopOrderBookProps {\n asks: any[];\n bids: any[];\n markPrice: number;\n lastPrice: number[];\n onItemClick?: (item: number[]) => void;\n depths: string[];\n activeDepth?: string;\n onDepthChange?: (depth: number) => void;\n //\n autoSize?: boolean;\n level?: number;\n base: string;\n quote: string;\n\n isLoading?: boolean;\n\n cellHeight?: number;\n\n className?: string;\n pendingOrders?: number[];\n symbolInfo: BasicSymbolInfo;\n}\n\nexport const DesktopOrderBook: FC<DesktopOrderBookProps> = (props) => {\n const { lastPrice, markPrice, quote, base, isLoading, onDepthChange } = props;\n // const onModeChange = useCallback((mode: QtyMode) => {}, []);\n\n //\n const divRef = useRef(null);\n const [showTotal, setShowTotal] = useState(false);\n\n const rangeInfo = [\n { left: 370, right: 600 },\n { left: 740, right: 800 },\n ];\n\n useEffect(() => {\n const resizeObserver = new ResizeObserver((entries) => {\n for (let entry of entries) {\n const { inlineSize: width } = entry.borderBoxSize[0];\n const count = rangeInfo.reduce(\n (a, b) => a + (width >= b.left && width < b.right ? 1 : 0),\n 0\n );\n setShowTotal(width >= 360);\n }\n });\n\n const targetDiv = divRef.current;\n\n if (targetDiv) {\n resizeObserver.observe(targetDiv);\n }\n\n return () => {\n if (targetDiv) {\n resizeObserver.unobserve(targetDiv);\n }\n };\n }, []);\n\n ///\n\n return (\n <OrderBookProvider\n cellHeight={props.cellHeight ?? 20}\n onItemClick={props.onItemClick}\n depth={props.activeDepth}\n showTotal={showTotal}\n pendingOrders={props.pendingOrders || []}\n symbolInfo={props.symbolInfo}\n >\n <div\n id=\"oui-orderbook-desktop\"\n className={cn(\"oui-h-full oui-w-full oui-relative\", props.className)}\n ref={divRef}\n >\n <DesktopDepthSelect\n depths={props.depths}\n value={props.activeDepth}\n onChange={onDepthChange}\n />\n <DesktopHeader quote={quote} base={base} />\n <DesktopAsks data={[...props.asks]} />\n <DesktopMarkPrice\n lastPrice={lastPrice}\n markPrice={markPrice}\n asks={[...props.asks]}\n bids={[...props.bids]}\n symbolInfo={props.symbolInfo}\n />\n <DesktopBids data={[...props.bids]}/>\n {isLoading && (\n <div className=\"oui-absolute oui-left-0 oui-top-0 oui-right-0 oui-bottom-0 oui-z-10 oui-flex oui-items-center oui-justify-center oui-bg-bg-8/70\">\n <Spinner />\n </div>\n )}\n </div>\n </OrderBookProvider>\n );\n};\n","import { FC, useCallback, useContext, useMemo, useState } from \"react\";\nimport { DesktopOrderBookCell } from \"./cell.desktop\";\nimport { OrderBookCellType } from \"../types\";\nimport { OrderBookContext, useOrderBookContext } from \"../orderContext\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n Text,\n Flex,\n TooltipRoot,\n TooltipArrow,\n} from \"@orderly.network/ui\";\nimport { BasicSymbolInfo } from \"../../../types/types\";\n\ninterface DesktopListBoxProps {\n type: OrderBookCellType;\n data: number[][];\n countQty: number;\n}\n\nexport const DesktopListBox: FC<DesktopListBoxProps> = (props) => {\n const { data, type } = props;\n const { symbolInfo, depth } = useOrderBookContext();\n\n const findMaxItem = useCallback(() => {\n if ((data?.length || 0) === 0) {\n return null;\n }\n if (type === OrderBookCellType.ASK) {\n const index = data.findIndex((item) => !Number.isNaN(item[0]));\n if (index != -1) {\n return data[index];\n }\n return null;\n } else {\n for (let index = data.length - 1; index >= 0; index--) {\n const item = data[index];\n\n if (!Number.isNaN(item[0])) {\n return item;\n }\n }\n return null;\n }\n }, [data, type]);\n\n const priceDp = useMemo(() => {\n if (depth?.toString().includes(\".\")) {\n return depth.toString().split(\".\")[1].length;\n }\n return 0;\n }, [depth]);\n\n const maxQty = useMemo(() => {\n return data.reduce((a, b) => Math.max(a, b[1]), 0);\n }, [data]);\n const [hoverIndex, setHoverIndex] = useState<number>(-1);\n\n return (\n <div\n id=\"oui-order-book-list\"\n className=\"oui-flex oui-flex-col oui-gap-[1px]\"\n >\n {data.map((item, index) => {\n return (\n <Tip\n key={index}\n index={index}\n item={item}\n countQty={props.countQty}\n setHoverIndex={setHoverIndex}\n hoverIndex={hoverIndex}\n type={type}\n maxQty={maxQty}\n priceDp={priceDp}\n symbolInfo={symbolInfo}\n findMaxItem={findMaxItem}\n />\n );\n })}\n </div>\n );\n};\n\nconst Tip: FC<{\n index: number;\n item: any;\n countQty: number;\n setHoverIndex: any;\n type: OrderBookCellType;\n maxQty: number;\n hoverIndex: number;\n priceDp: number;\n // base: any;\n // quote: any;\n // baseDp: number;\n // quoteDp: number;\n findMaxItem: () => number[] | null;\n symbolInfo: BasicSymbolInfo;\n}> = (props) => {\n const {\n index,\n item,\n setHoverIndex,\n type,\n maxQty,\n hoverIndex,\n priceDp,\n\n symbolInfo,\n } = props;\n\n const { base, quote, base_dp: baseDp, quote_dp: quoteDp } = symbolInfo;\n\n const isHover =\n hoverIndex !== -1\n ? type === OrderBookCellType.ASK\n ? index >= hoverIndex\n : index <= hoverIndex\n : false;\n\n const [open, setOpen] = useState(false);\n\n const calcHintInfo = (\n item: any\n ): {\n avgPrice: number;\n sumQty: number;\n sumQtyAmount: number;\n } => {\n if (item === null) {\n return {\n sumQty: 0,\n sumQtyAmount: 0,\n avgPrice: 0,\n };\n }\n let totalInfo = { sumQty: 0, sumQtyAmount: 0 };\n if (!Number.isNaN(item[2])) {\n totalInfo = {\n sumQty: item[2],\n sumQtyAmount: item[3],\n };\n }\n\n return {\n ...totalInfo,\n avgPrice:\n totalInfo.sumQtyAmount == 0\n ? 0\n : totalInfo.sumQtyAmount / totalInfo.sumQty,\n };\n };\n let hintInfo = calcHintInfo(item);\n if (hintInfo.avgPrice === 0) {\n hintInfo = calcHintInfo(props.findMaxItem());\n }\n\n return (\n <TooltipRoot open={open} onOpenChange={setOpen}>\n <TooltipTrigger>\n <DesktopOrderBookCell\n background={\"\"}\n price={item[0]}\n quantity={item[1]}\n accumulated={item[2]}\n count={props.countQty}\n type={props.type}\n accumulatedAmount={item[3]}\n maxQty={maxQty}\n isHover={isHover}\n currentHover={hoverIndex === index}\n symbolInfo={symbolInfo}\n onMouseEnter={() => {\n setHoverIndex(index);\n setOpen(true);\n }}\n onMouseLeave={() => {\n setHoverIndex(-1);\n setOpen(false);\n }}\n />\n </TooltipTrigger>\n <TooltipContent\n className=\"oui-max-w-[400px] oui-w-full oui-text-2xs oui-shadow-md oui-rounded-base oui-p-3 oui-bg-base-6 oui-flex oui-flex-col oui-gap-2\"\n align=\"center\"\n side=\"left\"\n sideOffset={12}\n onPointerEnter={(e) => e.preventDefault()}\n >\n <Row\n title=\"Avg. Price≈\"\n content={hintInfo.avgPrice}\n contentDp={priceDp}\n />\n <Row\n title={`Sum (${base})`}\n content={hintInfo.sumQty}\n contentDp={baseDp}\n />\n <Row\n title={`Sum (${quote})`}\n content={hintInfo.sumQtyAmount}\n contentDp={quoteDp}\n />\n\n <TooltipArrow className=\"oui-fill-base-6\" />\n </TooltipContent>\n </TooltipRoot>\n );\n};\n\nconst Row: FC<{ title: string; content: number; contentDp: number }> = (\n props\n) => {\n const { title, content, contentDp } = props;\n\n return (\n <div className=\"oui-flex oui-flex-row oui-justify-between oui-gap-4\">\n <div className=\"oui-text-base-contrast-36\">{title}</div>\n <div className=\"oui-text-right\">\n <Text.numeral dp={contentDp}>{content}</Text.numeral>\n </div>\n </div>\n );\n};\n","import { FC, useContext, useMemo } from \"react\";\nimport { getPrecisionByNumber } from \"@orderly.network/utils\";\nimport { OrderBookCellType } from \"../types\";\nimport { useOrderBookContext } from \"../orderContext\";\nimport { cn, Divider, parseNumber, Text } from \"@orderly.network/ui\";\nimport { CellBar, CellBarDirection } from \"../cellBar\";\nimport { BasicSymbolInfo } from \"../../../types/types\";\n\nexport interface DesktopOrderBookCellProps {\n background: string;\n maxQty: number;\n price: number;\n quantity: number;\n // size: number;\n count: number;\n accumulated: number;\n accumulatedAmount: number;\n type: OrderBookCellType;\n symbolInfo: BasicSymbolInfo;\n\n isHover: boolean;\n currentHover: boolean;\n onMouseEnter: () => void;\n onMouseLeave: () => void;\n}\n\nexport const DesktopOrderBookCell: FC<DesktopOrderBookCellProps> = (props) => {\n const { cellHeight, showTotal, onItemClick, depth, pendingOrders } =\n useOrderBookContext();\n const { symbolInfo, currentHover } = props;\n const { base_dp, quote_dp } = symbolInfo;\n\n const width = Number.isNaN(props.price)\n ? 0\n : (props.accumulated / props.count) * 100;\n\n const dp = useMemo(() => {\n return getPrecisionByNumber(depth || `${quote_dp}`);\n }, [depth, quote_dp]);\n\n const totalAmount = Number.isNaN(props.accumulated)\n ? \"-\"\n : props.accumulatedAmount?.toString();\n\n const isPendingOrder = useMemo(() => {\n const priceStr = parseNumber(props.price, { dp: dp, padding: true });\n\n const index = pendingOrders.findIndex(\n (item) => priceStr === parseNumber(item, { dp: dp, padding: true })\n );\n\n return index !== -1;\n }, [pendingOrders, props.price, depth]);\n\n return (\n <div\n className=\"oui-flex oui-flex-row oui-pl-3 oui-tabular-nums oui-justify-between oui-text-base-contrast-80 oui-text-3xs oui-relative oui-cursor-pointer\"\n style={{ height: `${cellHeight}px` }}\n onClick={() => {\n if (Number.isNaN(props.price) || Number.isNaN(props.quantity)) return;\n onItemClick?.([props.price, props.quantity]);\n }}\n onMouseEnter={props.onMouseEnter}\n onMouseLeave={props.onMouseLeave}\n >\n <div\n className={cn(\n \"oui-basis-7/12 oui-flex oui-felx-row oui-items-center oui-mr-2\",\n showTotal && \"oui-basis-5/12\"\n )}\n >\n <div\n className={cn(\n \"oui-flex-1 oui-text-left\",\n props.type === OrderBookCellType.ASK\n ? \"oui-text-trade-loss\"\n : \"oui-text-trade-profit\"\n )}\n >\n <Text.numeral dp={dp}>{props.price}</Text.numeral>\n </div>\n <div className=\"oui-flex-1 oui-text-right oui-text-base-contrast-80\">\n <Text.numeral dp={base_dp}>{props.quantity}</Text.numeral>\n </div>\n </div>\n <div\n className={cn(\n \"oui-basis-5/12 oui-flex oui-items-center oui-fex-row oui-overflow-hidden oui-relative\",\n showTotal && \"oui-basis-7/12\"\n )}\n >\n <div\n className={cn(\n \"oui-flex-1 oui-pr-6 oui-text-right\",\n showTotal && \"oui-pr-3\"\n )}\n >\n <Text.numeral dp={base_dp} className=\"oui-z-10\">\n {props.accumulated}\n </Text.numeral>\n </div>\n {showTotal && (\n <div className=\"oui-flex-1 oui-text-right oui-pr-3\">\n <Text.numeral dp={2} className=\"oui-z-10\">\n {totalAmount}\n </Text.numeral>\n </div>\n )}\n <CellBar\n width={width}\n direction={CellBarDirection.LEFT_TO_RIGHT}\n className={\n props.type === OrderBookCellType.ASK\n ? \"oui-bg-trade-loss/10\"\n : \"oui-bg-trade-profit/10\"\n }\n />\n </div>\n\n {isPendingOrder && (\n <div\n className={cn(\n \"oui-absolute oui-rounded-full oui-left-[-8px] oui-h-[4px] oui-w-[4px] oui-pointer-events-none\",\n props.type === OrderBookCellType.ASK && \"oui-bg-trade-loss\",\n props.type === OrderBookCellType.BID && \"oui-bg-trade-profit\"\n )}\n style={{ top: `${cellHeight / 2 - 2}px` }}\n />\n )}\n\n {props.isHover && (\n <div className=\"oui-absolute oui-bg-white oui-left-0 oui-right-0 oui-top-0 oui-bottom-0 oui-opacity-[.12]\"></div>\n )}\n {currentHover && (\n <div\n className={cn(\n \"oui-absolute oui-left-0 oui-right-0\",\n props.type === OrderBookCellType.ASK && \"oui-top-0\",\n props.type === OrderBookCellType.BID && \"oui-bottom-0\"\n )}\n >\n <Divider\n lineStyle=\"dashed\"\n className={cn(\n \"oui-w-full\",\n props.type === OrderBookCellType.BID && \"oui-border-trade-profit\",\n props.type === OrderBookCellType.ASK && \"oui-border-trade-loss\"\n )}\n />\n </div>\n )}\n </div>\n );\n};\n","import { createContext, FC, PropsWithChildren, useContext, useState } from \"react\";\nimport { QtyMode, TotalMode } from \"./types\";\nimport { BasicSymbolInfo } from \"../../types/types\";\n\nexport interface OrderBookContextValue {\n cellHeight: number;\n mode: QtyMode;\n depth?: string;\n onModeChange?: (mode: QtyMode) => void;\n onItemClick?: (item: number[]) => void;\n showTotal: boolean;\n totalMode: TotalMode;\n pendingOrders: number[];\n onTotalModeChange?: (mode: TotalMode) => void;\n symbolInfo: BasicSymbolInfo;\n}\n\nexport const OrderBookContext = createContext({\n cellHeight: 22,\n} as OrderBookContextValue);\n\nexport const useOrderBookContext = () => useContext(OrderBookContext);\n\ninterface OrderBookProviderProps {\n cellHeight: number;\n depth?: string;\n showTotal: boolean;\n pendingOrders: number[];\n onItemClick?: (item: number[]) => void;\n symbolInfo: BasicSymbolInfo;\n}\n\nexport const OrderBookProvider: FC<\n PropsWithChildren<OrderBookProviderProps>\n> = (props) => {\n const [mode, setMode] = useState<QtyMode>(\"quantity\");\n const [totalMode, setTotalMode] = useState<QtyMode>(\"quantity\");\n return (\n <OrderBookContext.Provider\n value={{\n cellHeight: props.cellHeight,\n onItemClick: props.onItemClick,\n mode,\n totalMode: totalMode || \"quantity\",\n depth: props.depth,\n onModeChange: setMode,\n onTotalModeChange: setTotalMode,\n showTotal: props.showTotal || false,\n pendingOrders: props.pendingOrders,\n symbolInfo: props.symbolInfo,\n }}\n >\n {props.children}\n </OrderBookContext.Provider>\n );\n};\n","import { cn } from \"@orderly.network/ui\";\nimport { FC, useMemo } from \"react\";\n\nexport enum CellBarDirection {\n LEFT_TO_RIGHT,\n RIGHT_TO_LEFT,\n}\n\ninterface CellBarProps {\n width: number;\n className?: string;\n direction?: CellBarDirection\n}\n\nexport const CellBar: FC<CellBarProps> = (props) => {\n const { direction = CellBarDirection.RIGHT_TO_LEFT } = props;\n const transform = useMemo(() => {\n const x = Math.max(props.width, 0);\n if (direction === CellBarDirection.LEFT_TO_RIGHT) {\n return { transform: `translateX(${x}%)` };\n }\n return { transform: `translateX(-${x}%)` };\n \n }, [props.width]);\n\n return (\n <div\n className={cn(\n \"oui-absolute oui-right-[-100%] oui-top-0 oui-h-full oui-w-full oui-transition-transform oui-pointer-events-none\",\n direction === CellBarDirection.LEFT_TO_RIGHT && \"oui-left-[-100%]\",\n props.className\n )}\n style={transform}\n />\n );\n};\n","\nimport { OrderBookCellType } from \"../types\";\nimport { DesktopListBox } from \"./listBox.desktop\";\nimport { FC, useMemo } from \"react\";\n\nexport interface Props {\n data: any[];\n}\nexport const DesktopBids: FC<Props> = (props) => {\n const { data } = props;\n const countQty = useMemo(() => {\n let max = Number.NaN;\n // let len = data.length;\n let index = data.length - 1;\n\n while (Number.isNaN(max) && index > 0) {\n max = data[index][2];\n index--;\n }\n\n return max;\n // return data.length > 0 ? data[data.length - 1][2] : 0;\n }, [data]);\n return (\n <DesktopListBox type={OrderBookCellType.BID} data={data} countQty={countQty} />\n );\n};\n","import { Box } from \"@orderly.network/ui\";\nimport { BasicSymbolInfo } from \"../../../types/types\";\nimport { OrderBookCellType } from \"../types\";\nimport { DesktopListBox } from \"./listBox.desktop\";\nimport { FC, useMemo } from \"react\";\nimport { useOrderBookContext } from \"../orderContext\";\nexport interface Props {\n data: number[][];\n}\nexport const DesktopAsks: FC<Props> = (props) => {\n const { data } = props;\n const countQty = useMemo(() => {\n let max = Number.NaN;\n let len = data.length;\n let index = 0;\n\n while (Number.isNaN(max) && index < len) {\n max = data[index][2];\n index++;\n }\n\n return max;\n }, [data]);\n \n return (\n <DesktopListBox type={OrderBookCellType.ASK} data={data} countQty={countQty} />\n );\n};\n","import { FC, useMemo } from \"react\";\nimport { commify, commifyOptional, Decimal } from \"@orderly.network/utils\";\nimport {\n ArrowDownShortIcon,\n ArrowUpShortIcon,\n Box,\n cn,\n Flex,\n Text,\n Tooltip,\n} from \"@orderly.network/ui\";\nimport { BasicSymbolInfo } from \"../../../types/types\";\nimport { useOrderBookContext } from \"../orderContext\";\n\ninterface DesktopMarkPriceProps {\n markPrice: number;\n lastPrice: number[];\n asks: number[][];\n bids: number[][];\n symbolInfo: BasicSymbolInfo;\n}\n\nexport const DesktopMarkPrice: FC<DesktopMarkPriceProps> = (props) => {\n const { markPrice = 0, lastPrice, asks, bids, symbolInfo } = props;\n const { showTotal } = useOrderBookContext();\n\n return (\n <Flex py={1} pl={3} pr={showTotal ? 3 : 6} justify={\"between\"}>\n <Flex gap={2}>\n <MiddlePriceView\n markPrice={markPrice}\n lastPrice={lastPrice}\n quote_dp={symbolInfo.quote_dp}\n />\n <MarkPriceView markPrice={markPrice} quote_dp={symbolInfo.quote_dp} />\n </Flex>\n <Spread asks={asks} bids={bids} />\n </Flex>\n );\n};\n\n/**\n * default style is desktop effect\n */\nexport const MiddlePriceView: FC<{\n markPrice: number;\n lastPrice: number[];\n quote_dp: number;\n className?: string;\n iconSize?: number;\n}> = (props) => {\n const {\n markPrice = 0,\n lastPrice,\n quote_dp,\n className,\n iconSize = 18,\n } = props;\n\n const [prevLastPrice, middlePrice] = lastPrice;\n\n return (\n <Flex\n gap={1}\n className={cn(\n middlePrice > prevLastPrice\n ? \"oui-text-trade-profit\"\n : \"oui-text-trade-loss\",\n className\n )}\n >\n <Text.numeral dp={quote_dp}>{middlePrice}</Text.numeral>\n <Box width={19}>\n {middlePrice < prevLastPrice && (\n <ArrowDownShortIcon size={iconSize} color=\"danger\" opacity={1} />\n )}\n {middlePrice > prevLastPrice && (\n <ArrowUpShortIcon size={iconSize} color=\"success\" opacity={1} />\n )}\n </Box>\n </Flex>\n );\n};\n\n/**\n * default style is desktop effect\n */\nexport const MarkPriceView: FC<{\n markPrice: number;\n quote_dp: number;\n className?: string;\n iconSize?: number;\n}> = (props) => {\n const { quote_dp, className, iconSize = 18 } = props;\n\n return (\n <Tooltip\n content={\n \"Obtained from a third-party oracle, the mark price is calculated as the median of three prices: the last price, the fair price based on the funding rate basis, and the fair price based on the order books.\"\n }\n className=\"oui-max-w-[270px]\"\n >\n <Flex\n gap={1}\n className={cn(\"oui-cursor-pointer oui-text-2xs\", className)}\n >\n <FlagIcon size={iconSize} />\n <Text.numeral\n dp={quote_dp}\n color=\"warning\"\n className=\"oui-underline oui-decoration-dashed oui-decoration-1 oui-underline-offset-4 oui-decoration-warning\"\n >\n {props.markPrice}\n </Text.numeral>\n </Flex>\n </Tooltip>\n );\n};\n\nconst Spread: FC<{\n asks: number[][];\n bids: number[][];\n}> = (props) => {\n const { asks, bids } = props;\n\n const spread = useMemo(() => {\n if (bids.length === 0 && asks.length === 0) {\n return 0;\n }\n const bid1 = Number.isNaN(bids[0][0]) ? 0 : bids[0][0];\n const index = asks.reverse().findIndex((item) => !Number.isNaN(item[0]));\n\n let ask1 = 0.0;\n if (index !== -1) {\n ask1 = Number.isNaN(asks[index][0]) ? 0 : asks[index][0];\n }\n const dValue = new Decimal(ask1)\n .sub(bid1)\n .div(new Decimal(ask1).add(bid1).div(2));\n // 0.00006416604461251195\n // 0.000065\n // 0.0065\n return Math.ceil(dValue.toNumber() * 1000000 + 0.1) / 10000;\n }, [asks, bids]);\n\n return (\n <div>\n <Tooltip\n content={\"Spread Ratio of the ask1 and bid1.\"}\n className=\"oui-max-w-[240px]\"\n >\n <Text\n size=\"2xs\"\n intensity={36}\n className={\n \"oui-cursor-pointer oui-underline oui-decoration-dashed oui-decoration-1 oui-underline-offset-4 oui-decoration-base-contrast-36\"\n }\n >\n {`${spread}%`}\n </Text>\n </Tooltip>\n </div>\n );\n};\n\nconst FlagIcon = (props: { size: number }) => {\n return (\n <svg\n width={props.size}\n height={props.size}\n viewBox=\"0 0 18 18\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M3.75 1.5a.75.75 0 0 1 .75.75h6a.75.75 0 0 1 .75.75v1.5h3a.75.75 0 0 1 .75.75V12a.75.75 0 0 1-.75.75H7.5a.75.75 0 0 1-.75-.75v-1.5H4.5v5.25a.75.75 0 0 1-1.5 0V2.25a.75.75 0 0 1 .75-.75M4.5 9h5.25V3.75H4.5zm6.75-3v3.75a.75.75 0 0 1-.75.75H8.25v.75h5.25V6z\"\n fill=\"#FF7D00\"\n />\n </svg>\n );\n};\n","import { FC, useContext, useMemo } from \"react\";\nimport { OrderBookContext } from \"../orderContext\";\nimport { Box, cn, Flex } from \"@orderly.network/ui\";\n\ninterface Props {\n quote: string;\n base: string;\n}\n\nexport const DesktopHeader: FC<Props> = (props) => {\n const { showTotal } = useContext(OrderBookContext);\n return (\n <Flex pl={3} justify={\"between\"} className=\"oui-py-[6px]\">\n <Flex gap={1} className={cn(\"oui-basis-7/12\", showTotal && \"oui-basis-1/2\")}>\n <Box width={\"100%\"}>\n <Title\n name=\"Price\"\n token={props.quote}\n id=\"oui-order-book-header-price\"\n />\n </Box>\n <Box width={\"100%\"}>\n <Title\n name=\"Qty\"\n token={props.base}\n id=\"oui-order-book-header-qty\"\n justifyEnd\n />\n </Box>\n </Flex>\n <Flex gap={1} pr={3} className={cn(\"oui-basis-5/12\", showTotal && \"oui-basis-1/2\")}>\n <Box width={\"100%\"}>\n <Title\n name=\"Total\"\n token={props.base}\n id=\"oui-order-book-header-total-base\"\n justifyEnd\n />\n </Box>\n {showTotal && (\n <Box width={\"100%\"}>\n <Title\n name=\"Total\"\n token={props.quote}\n id=\"oui-order-book-header-total-quote\"\n justifyEnd\n />\n </Box>\n )}\n </Flex>\n </Flex>\n );\n};\n\nconst Title: FC<{\n name: string;\n token: string;\n justifyEnd?: boolean;\n id?: string;\n}> = (props) => {\n const { name, token, justifyEnd = false } = props;\n return (\n <Flex\n id={props.id}\n className={cn(\n \"oui-text-base-contrast-36 oui-text-xs oui-items-end\",\n justifyEnd && \"oui-justify-end\"\n )}\n >\n <span>{name}</span>\n <span>{`(${token})`}</span>\n </Flex>\n );\n};\n","import { Box, Select } from \"@orderly.network/ui\";\nimport { FC, useMemo } from \"react\";\n\ninterface DesktopDepthSelectProps {\n depths: string[];\n value?: string;\n onChange?: (depth: number) => void;\n}\n\nexport const DesktopDepthSelect: FC<DesktopDepthSelectProps> = (props) => {\n const options = useMemo(() => {\n return props.depths.map((d) => ({\n value: d,\n label: `${d}`,\n }));\n }, [props.depths]);\n\n return (\n <Box pl={3} width={97} className=\"oui-py-[10px]\">\n <Select.options\n options={options}\n size={\"xs\"}\n value={props.value}\n onValueChange={(value: any) => {\n props.onChange?.(value);\n }}\n />\n </Box>\n );\n};\n","import { FC, useMemo } from \"react\";\n\nimport { useOrderBookContext } from \"../orderContext\";\nimport { Flex, Text } from \"@orderly.network/ui\";\n\ninterface Props {\n quote: string;\n base: string;\n}\n\nexport const Header: FC<Props> = (props) => {\n const { mode, onModeChange } = useOrderBookContext();\n const currency = useMemo(() => {\n if (mode === \"amount\") {\n return props.quote;\n }\n return props.base;\n }, [mode, props.quote, props.base]);\n\n const qtyLabel = useMemo(() => {\n return mode === \"amount\" ? \"Value\" : \"Qty\";\n }, [mode]);\n\n return (\n <Flex\n justify={\"between\"}\n width={\"100%\"}\n className=\"oui-text-base-contrast-36 oui-text-2xs oui-py-[5px]\"\n >\n <Flex\n direction={\"column\"}\n itemAlign={\"start\"}\n id=\"oui-order-book-header-price\"\n >\n <Text>Price</Text>\n <Text>{`(${props.quote})`}</Text>\n </Flex>\n <Flex\n direction={\"column\"}\n itemAlign={\"end\"}\n className=\"oui-cursor-pointer\"\n onClick={() =>\n onModeChange?.(mode === \"amount\" ? \"quantity\" : \"amount\")\n }\n >\n <Text>{qtyLabel}</Text>\n <Text>{`(${currency})`}</Text>\n </Flex>\n </Flex>\n );\n};\n","import { FC, useContext, useMemo } from \"react\";\nimport { CellBar } from \"../cellBar\";\nimport { Decimal, getPrecisionByNumber } from \"@orderly.network/utils\";\nimport { OrderBookCellType, QtyMode } from \"../types\";\nimport { OrderBookContext } from \"../orderContext\";\nimport { Box, cn, Flex, Text } from \"@orderly.network/ui\";\n\nexport interface OrderBookCellProps {\n background: string;\n price: number;\n quantity: number;\n // size: number;\n count: number;\n accumulated: number;\n type: OrderBookCellType;\n mode: QtyMode;\n}\n\nexport const OrderBookCell: FC<OrderBookCellProps> = (props) => {\n const width = (props.accumulated / props.count) * 100;\n const { cellHeight, onItemClick, depth, showTotal, symbolInfo } =\n useContext(OrderBookContext);\n const { base_dp, quote_dp } = symbolInfo;\n\n let qty = Number.isNaN(props.quantity)\n ? \"-\"\n : props.mode === \"amount\"\n ? new Decimal(props.quantity).mul(props.price).toString()\n : props.quantity;\n\n if (showTotal) {\n qty = props.quantity;\n }\n\n const dp = useMemo(() => {\n return getPrecisionByNumber(depth || `${quote_dp}`);\n }, [depth, quote_dp]);\n\n return (\n <Box\n className={cn(\n \"oui-overflow-hidden oui-relative oui-cursor-pointer oui-tabular-nums oui-text-2xs oui-w-full\",\n showTotal && \"oui-flex-1\"\n )}\n style={{ height: `${cellHeight}px` }}\n onClick={(e) => {\n if (Number.isNaN(props.price) || Number.isNaN(props.quantity)) return;\n\n onItemClick?.([props.price, props.quantity]);\n }}\n >\n <Flex justify={\"between\"}>\n <Text.numeral\n color={props.type === OrderBookCellType.BID ? \"buy\" : \"sell\"}\n dp={dp}\n >\n {props.price}\n </Text.numeral>\n <Text.numeral\n dp={props.mode === \"amount\" ? 2 : base_dp}\n className=\"oui-text-base-contrast-80\"\n >\n {qty}\n </Text.numeral>\n </Flex>\n {Number.isNaN(width) || showTotal ? null : (\n <CellBar\n width={width}\n className={\n props.type === OrderBookCellType.ASK\n ? \"oui-bg-trade-loss/20\"\n : \"oui-bg-trade-profit/20\"\n }\n />\n )}\n </Box>\n );\n};\n","import { FC, useContext, useMemo } from \"react\";\nimport { OrderBookCell } from \"./cell\";\nimport { OrderBookContext, useOrderBookContext } from \"../orderContext\";\nimport { OrderBookCellType } from \"../types\";\nimport { Box } from \"@orderly.network/ui\";\n\ninterface OrderBookListProps {\n type: OrderBookCellType;\n data: number[][];\n countQty: number;\n}\n\nexport const ListBox: FC<OrderBookListProps> = (props) => {\n const { data } = props;\n const { mode } = useOrderBookContext();\n\n return (\n <Box\n id=\"oui-order-book-list\"\n className=\"oui-flex oui-flex-col oui-gap-[1px] oui-w-full\"\n >\n {data.map((item, index) => {\n return (\n <OrderBookCell\n key={index}\n background={\"\"}\n price={item[0]}\n quantity={item[1]}\n accumulated={item[2]}\n count={props.countQty}\n type={props.type}\n mode={mode}\n />\n );\n })}\n </Box>\n );\n};\n","import { OrderBookCellType } from \"../types\";\nimport { ListBox } from \"./listBox\";\nimport { FC, useMemo } from \"react\";\n\nexport interface Props {\n data: any[];\n}\nexport const Bids: FC<Props> = (props) => {\n const { data } = props;\n const countQty = useMemo(() => {\n let max = Number.NaN;\n // let len = data.length;\n let index = data.length - 1;\n\n while (Number.isNaN(max) && index > 0) {\n max = data[index][2];\n index--;\n }\n\n return max;\n // return data.length > 0 ? data[data.length - 1][2] : 0;\n }, [data]);\n return (\n <ListBox type={OrderBookCellType.BID} data={data} countQty={countQty} />\n );\n};\n","import { OrderBookCellType } from \"../types\";\nimport { ListBox } from \"./listBox\";\nimport { FC, useMemo } from \"react\";\nexport interface Props {\n data: number[][];\n}\nexport const Asks: FC<Props> = (props) => {\n const { data } = props;\n const countQty = useMemo(() => {\n let max = Number.NaN;\n let len = data.length;\n let index = 0;\n\n while (Number.isNaN(max) && index < len) {\n max = data[index][2];\n index++;\n }\n\n return max;\n }, [data]);\n return (\n <ListBox type={OrderBookCellType.ASK} data={data} countQty={countQty} />\n );\n};\n","import { FC } from \"react\";\nimport { Flex, Text, cn, modal } from \"@orderly.network/ui\";\nimport { useOrderBookContext } from \"../orderContext\";\nimport { MarkPriceView, MiddlePriceView } from \"../desktop/markPrice.desktop\";\n\ninterface MarkPriceProps {\n markPrice: number;\n lastPrice: number[];\n}\n\nexport const MarkPrice: FC<MarkPriceProps> = (props) => {\n const { markPrice = 0, lastPrice } = props;\n\n const { symbolInfo } = useOrderBookContext();\n\n const { quote_dp } = symbolInfo;\n\n const [prevLastPrice, middlePrice] = lastPrice;\n\n //\n //\n\n const onMarkPrice = () => {\n modal.alert({\n title: \"Mark price\",\n message: (\n <span className=\"oui-text-3xs oui-text-base-contrast-54\">\n Obtained from a third-party oracle, the mark price is calculated as\n the median of three prices: the last price, the fair price based on\n the funding rate basis, and the fair price based on the order books.\n </span>\n ),\n });\n };\n\n return (\n <Flex id=\"oui-order-book-mark-price\" className=\"oui-py-[6px]\" width={\"100%\"} justify={\"between\"}>\n <MiddlePriceView\n markPrice={props.markPrice}\n lastPrice={props.lastPrice}\n quote_dp={quote_dp}\n className=\"oui-text-sm\"\n iconSize={14}\n />\n <MarkPriceView\n markPrice={props.markPrice}\n quote_dp={quote_dp}\n className=\"oui-text-2xs\"\n iconSize={12}\n />\n </Flex>\n );\n};\n","import { Flex, Box, Picker } from \"@orderly.network/ui\";\nimport { FC, useMemo } from \"react\";\n\ninterface DepthSelectProps {\n depth: string[];\n value?: string;\n onChange?: (depth: number) => void;\n}\n\nexport const DepthSelect: FC<DepthSelectProps> = (props) => {\n const options = useMemo(() => {\n return props.depth.map((d) => ({\n value: d,\n label: `${d}`,\n }));\n }, [props.depth]);\n return (\n <Box id=\"oui-order-book-depth\" className=\"oui-pt-2\" >\n {/* <Select size={\"small\"} value={\"0.001\"} /> */}\n <Picker\n options={options}\n fullWidth\n size={\"sm\"}\n value={props.value}\n className=\"oui-text-2xs oui-text-base-contrast-54 \"\n onValueChange={(value) => {\n //\n props.onChange?.(value);\n }}\n />\n </Box>\n );\n};\n","import React, { FC, useCallback, useEffect, useRef, useState } from \"react\";\nimport { Header } from \"./header\";\nimport { Bids } from \"./bids\";\nimport { Asks } from \"./asks\";\nimport { MarkPrice } from \"./markPrice\";\nimport { OrderBookProvider } from \"../orderContext\";\nimport { DepthSelect } from \"./depthSelect\";\nimport { cn, Flex, Spinner } from \"@orderly.network/ui\";\nimport { BasicSymbolInfo } from \"../../../types/types\";\nimport { FundingRateWidget } from \"../fundingRate\";\nexport interface OrderBookProps {\n asks: any[];\n bids: any[];\n markPrice: number;\n lastPrice: number[];\n onItemClick?: (item: number[]) => void;\n depths?: string[];\n activeDepth?: string;\n onDepthChange?: (depth: number) => void;\n //\n autoSize?: boolean;\n level?: number;\n base: string;\n quote: string;\n\n isLoading?: boolean;\n\n cellHeight?: number;\n\n className?: string;\n symbolInfo: BasicSymbolInfo;\n}\n\nexport const OrderBook: FC<OrderBookProps> = (props) => {\n const { lastPrice, markPrice, quote, base, isLoading, onDepthChange } = props;\n // const onModeChange = useCallback((mode: QtyMode) => {}, []);\n const symbol = `PERP_${props.symbolInfo.base}_${props.symbolInfo.quote}`;\n\n return (\n <OrderBookProvider\n cellHeight={props.cellHeight ?? 20}\n onItemClick={props.onItemClick}\n depth={props.activeDepth}\n pendingOrders={[]}\n showTotal={false}\n symbolInfo={props.symbolInfo}\n >\n <Flex\n direction={\"column\"}\n p={2}\n id=\"oui-orderbook-mobile\"\n className={cn(\"oui-h-full oui-wfull oui-relative\", props.className)}\n justify={\"start\"}\n itemAlign={\"start\"}\n >\n <FundingRateWidget symbol={symbol} />\n <Header quote={quote} base={base} />\n <Asks data={props.asks} />\n <MarkPrice lastPrice={lastPrice} markPrice={markPrice} />\n <Bids data={props.bids} />\n\n <DepthSelect\n depth={props.depths || []}\n value={props.activeDepth}\n onChange={onDepthChange}\n />\n {isLoading && (\n <div className=\"oui-absolute oui-left-0 oui-top-0 oui-right-0 oui-bottom-0 oui-z-10 oui-flex oui-items-center oui-justify-center oui-bg-base-800/70 oui-h-full oui-min-h-[420px]\">\n <Spinner />\n </div>\n )}\n </Flex>\n </OrderBookProvider>\n );\n};\n","import { FC } from \"react\";\nimport { Flex, Text } from \"@orderly.network/ui\";\nimport { FundingRateState } from \"./fundingRate.script\";\n\nexport const FundingRate: FC<FundingRateState> = (props) => {\n const predFundingRate = props.data.est_funding_rate;\n const countDown = props.data.countDown;\n\n return (\n <Flex direction={\"column\"} itemAlign={\"start\"} pb={2}>\n <Text intensity={36} size=\"2xs\">\n Pred. funding rate\n </Text>\n\n {predFundingRate === null ? (\n \"--\"\n ) : (\n <div className=\"orderly-flex orderly-gap-1 oui-text-2xs\">\n <span className=\"orderly-text-warning\">{`${predFundingRate}%`}</span>\n <span>in</span>\n <span>{countDown}</span>\n </div>\n )}\n </Flex>\n );\n};\n","import { useFundingRate } from \"@orderly.network/hooks\";\n\nexport const useFundingRateScript = (symbol: string) => {\n const data = useFundingRate(symbol);\n return { data };\n};\n\nexport type FundingRateState = ReturnType<typeof useFundingRateScript>;\n","import { useFundingRateScript } from \"./fundingRate.script\";\nimport { FundingRate } from \"./fundingRate.ui\";\n\nexport const FundingRateWidget = (props: { symbol: string }) => {\n const state = useFundingRateScript(props.symbol);\n return <FundingRate {...state} />;\n};\n","import { useEffect, useMemo, useState } from \"react\";\nimport { useTradingPateContext } from \"../../provider/context\";\nimport {\n useMediaQuery,\n useOrderbookStream,\n useOrderStream,\n useSymbolsInfo,\n} from \"@orderly.network/hooks\";\nimport { removeTrailingZeros } from \"@orderly.network/utils\";\nimport { MEDIA_TABLET, OrderStatus } from \"@orderly.network/types\";\nimport { getBasicSymbolInfo } from \"../../utils/utils\";\n\nconst CELL_MAX = 30;\nconst DEFAULT_CELL_HEIGHT = 20;\n\nconst SPACE = 104;\n\nexport const useOrderBookScript = (props: {\n symbol: string;\n height?: number;\n}) => {\n const { symbol, height } = props;\n const symbolInfo = useSymbolsInfo()[props.symbol];\n\n const [cellHeight, setCellHeight] = useState(DEFAULT_CELL_HEIGHT);\n\n const [level, setLevel] = useState(10);\n const { base, quote, quote_dp } = getBasicSymbolInfo(symbolInfo);\n\n const [data, { onDepthChange, isLoading, onItemClick, depth, allDepths }] =\n useOrderbookStream(symbol, undefined, {\n level,\n padding: false,\n });\n\n const pendingOrders = usePendingOrderStream(symbol);\n\n // const { height } = useTabContext();\n\n useEffect(() => {\n if (height) {\n // setCellHeight(height.content / level);\n const level = Math.floor(\n (height - SPACE) / ((DEFAULT_CELL_HEIGHT + 1) * 2)\n );\n\n const cellsHeight = (DEFAULT_CELL_HEIGHT + 1) * 2 * level;\n\n const restSpace = height - SPACE - cellsHeight;\n\n console.log(\n \"restSpace\",\n level,\n height,\n SPACE,\n cellsHeight,\n restSpace\n );\n\n if (restSpace > 10) {\n setCellHeight(DEFAULT_CELL_HEIGHT + restSpace / level / 2);\n } else {\n setCellHeight(DEFAULT_CELL_HEIGHT);\n }\n\n setLevel(level);\n }\n }, [height]);\n\n const selDepth = useMemo(() => {\n if (typeof depth === \"undefined\" || typeof quote_dp === \"undefined\") {\n return undefined;\n }\n\n let formattedNumber = removeTrailingZeros(depth);\n return formattedNumber;\n }, [depth, quote_dp]);\n\n const depths = useMemo(() => {\n return allDepths?.map((e) => removeTrailingZeros(e)) || [];\n }, [allDepths, quote_dp]);\n\n const isMWeb = useMediaQuery(MEDIA_TABLET);\n\n return {\n level,\n asks: data?.asks,\n bids: data?.bids,\n markPrice: data?.markPrice,\n lastPrice: data?.middlePrice,\n depths,\n selDepth,\n base,\n quote,\n isLoading,\n onItemClick,\n cellHeight,\n onDepthChange,\n pendingOrders,\n symbolInfo: getBasicSymbolInfo(symbolInfo),\n isMWeb,\n };\n};\n\nexport const usePendingOrderStream = (symbol: string): number[] => {\n const [data] = useOrderStream({\n status: OrderStatus.INCOMPLETE,\n symbol: symbol,\n });\n\n const pendingOrders = useMemo(() => {\n const info = data\n ?.filter((item) => item.symbol === symbol)\n .reduce((a, b) => {\n // TODO: check if this is the correct price, when the data is from WS, it crashes\n const price = b.price || b.trigger_price || 0;\n return [...a, price];\n }, []);\n\n return info;\n }, [data, symbol]);\n\n return pendingOrders;\n};\n\nexport type OrderBookState = ReturnType<typeof useOrderBookScript>;\n","import { utils } from \"@orderly.network/hooks\";\nimport { API } from \"@orderly.network/types\";\nimport { BasicSymbolInfo } from \"../types/types\";\n\nexport const getBasicSymbolInfo = (\n symbolInfo: (\n key?: keyof API.SymbolExt | undefined,\n defaultValue?: utils.ValueOf<API.SymbolExt> | undefined\n ) => any\n): BasicSymbolInfo => {\n return {\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 };\n};\n","import { useOrderBookScript } from \"./orderBook.script\";\nimport { OrderBook } from \"./orderBook.ui\";\n\nexport const OrderBookWidget = (props: {\n className?: string;\n symbol: string;\n height?: number;\n}) => {\n const state = useOrderBookScript({\n symbol: props.symbol,\n height: props.height,\n });\n return <OrderBook {...state} className={props.className} />;\n};\n","import React, { FC } from \"react\";\nimport {\n Flex,\n Text,\n Box,\n Tooltip,\n modal,\n gradientTextVariants,\n cn,\n} from \"@orderly.network/ui\";\nimport { RiskRateState } from \"./riskRate.script\";\nimport { Pencil } from \"lucide-react\";\nimport { LeverageWidgetId } from \"@orderly.network/ui-leverage\";\n\nexport const RiskRate: FC<RiskRateState> = (props) => {\n const { riskRate, riskRateColor, isConnected, currentLeverage, maxLeverage } =\n props;\n const { isHigh, isMedium, isLow, isDefault } = riskRateColor;\n\n const textColor = isHigh\n ? \"oui-text-danger\"\n : isMedium\n ? \"oui-text-warning\"\n : isLow\n ? gradientTextVariants({ color: \"brand\" })\n : \"\";\n\n return (\n <Box data-risk={\"\"} className=\"oui-space-y-2\">\n <Flex\n itemAlign=\"center\"\n justify=\"start\"\n className=\"oui-w-full oui-bg-base-6 oui-rounded-full oui-h-2 oui-px-[1px]\"\n >\n {isDefault ? (\n <Box\n className=\"oui-bg-gradient-to-r oui-opacity-20 oui-from-[#26fefe] oui-via-[#ff7d00] oui-to-[#d92d6b] oui-h-1.5 oui-rounded-full\"\n style={{ width: \"100%\" }}\n />\n ) : null}\n\n {isHigh ? (\n <Box\n className=\"oui-bg-gradient-to-tr oui-from-[#791438] oui-to-[#ff447c] oui-h-1.5 oui-rounded-full\"\n style={{ width: riskRate }}\n />\n ) : null}\n\n {isMedium ? (\n <Box\n className=\"oui-bg-gradient-to-tr oui-from-[#792e00] oui-to-[#ffb65d] oui-h-1.5 oui-rounded-full\"\n style={{ width: riskRate }}\n />\n ) : null}\n\n {isLow ? (\n <Box\n className=\"oui-bg-gradient-to-tr oui-from-[#59b0fe] oui-to-[#26fefe] oui-h-1.5 oui-rounded-full\"\n style={{ width: riskRate }}\n />\n ) : null}\n </Flex>\n\n <Flex className=\"oui-gap-2\">\n <Flex direction=\"column\" itemAlign=\"start\" className=\"oui-flex-1\">\n <Tooltip content={(<div>hint test</div>) as any}>\n <Text\n size=\"2xs\"\n color=\"neutral\"\n weight=\"semibold\"\n className=\"oui-cursor-pointer\"\n >\n Risk rate\n </Text>\n </Tooltip>\n <Text\n size=\"xs\"\n color=\"neutral\"\n weight=\"semibold\"\n className={cn(textColor)}\n >\n {riskRate}\n </Text>\n </Flex>\n\n <Flex direction=\"column\" itemAlign=\"end\" className=\"oui-flex-1\">\n <Tooltip content={(<div>hint test</div>) as any}>\n <Text\n size=\"2xs\"\n color=\"neutral\"\n weight=\"semibold\"\n className=\"oui-cursor-pointer\"\n >\n Max account leverage\n </Text>\n </Tooltip>\n <Flex className=\"oui-gap-1\">\n {isConnected ? (\n <Text.numeral suffix={\"x\"}>{currentLeverage}</Text.numeral>\n ) : (\n \"--\"\n )}\n\n <span className={\"oui-text-base-contrast-54\"}>/</span>\n\n {\n // modal.show(LeverageWidgetId, { currentLeverage: 5 });\n isConnected ? (\n <button\n className=\"oui-flex oui-items-center oui-gap-1\"\n onClick={() => {\n modal.show(LeverageWidgetId, { currentLeverage: 5 });\n }}\n >\n <span>{`${maxLeverage ?? \"--\"}x`}</span>\n {typeof maxLeverage !== \"undefined\" && (\n // @ts-ignore\n <Pencil size={14} className=\"oui-text-base-contrast-54\" />\n )}\n </button>\n ) : (\n \"--\"\n )\n }\n </Flex>\n </Flex>\n </Flex>\n </Box>\n );\n};\n","import { useAccount, useLeverage, useMarginRatio } from \"@orderly.network/hooks\";\nimport { AccountStatusEnum } from \"@orderly.network/types\";\nimport { useMemo } from \"react\";\nimport { Decimal } from \"@orderly.network/utils\";\n\nconst getRiskRateColor = (riskRate: null | number) => {\n if (riskRate === null) {\n return { isHigh: false, isMedium: false, isLow: false, isDefault: true };\n }\n\n const isLow = riskRate < 40;\n const isMedium = riskRate >= 40 && riskRate < 80;\n const isHigh = riskRate >= 80;\n const isDefault = !isLow && !isMedium && !isHigh;\n\n return { isHigh, isMedium, isLow, isDefault };\n};\n\nexport const useRiskRateScript = () => {\n const { state } = useAccount();\n\n const isConnected = state.status >= AccountStatusEnum.Connected;\n const { marginRatio,currentLeverage, mmr } = useMarginRatio();\n const [maxLeverage] = useLeverage();\n\n const riskRate = useMemo(() => {\n if (!isConnected || marginRatio === null || mmr === null) {\n return \"0%\";\n }\n\n if (marginRatio === 0 || mmr === 0) {\n return \"0%\";\n }\n\n const calculatedRiskRate = new Decimal(mmr)\n .div(marginRatio)\n .mul(100)\n .todp(2, Decimal.ROUND_UP);\n\n // Remove trailing zeroes and add percentage sign\n return `${calculatedRiskRate.toString().replace(/\\.?0+$/, \"\")}%`;\n }, [isConnected, marginRatio, mmr]);\n\n const riskRateNumber = riskRate === \"--\" ? null : parseFloat(riskRate);\n\n const riskRateColor = useMemo(() => {\n return getRiskRateColor(riskRateNumber);\n }, [riskRateNumber]);\n\n return {\n riskRate,\n riskRateColor,\n isConnected,\n currentLeverage,\n maxLeverage\n };\n};\n\nexport type RiskRateState = ReturnType<typeof useRiskRateScript>;\n","import { useRiskRateScript } from \"./riskRate.script\";\nimport { RiskRate } from \"./riskRate.ui\";\n\nexport const RiskRateWidget = () => {\n const state = useRiskRateScript();\n return (<RiskRate {...state} />);\n};\n","import { FC, useEffect, useRef } from \"react\";\nimport { Box, cn, Flex, Grid, TabPanel, Tabs, Text } from \"@orderly.network/ui\";\nimport { OrderBookAndTradesState } from \"./orderBookAndTrades.script\";\nimport { OrderBookWidget } from \"../orderBook\";\nimport { LastTradesWidget } from \"../lastTrades\";\n\nexport const OrderBookAndTrades: FC<OrderBookAndTradesState> = (props) => {\n return (\n <div ref={props.containerRef} className=\"oui-h-full\">\n {(props.containerSize?.width || 0) >= 572 ? (\n <TwoColLayout {...props} />\n ) : (\n <TabLayout {...props} />\n )}\n </div>\n );\n};\n\nconst TwoColLayout: FC<OrderBookAndTradesState> = (props) => {\n return (\n <Grid\n cols={2}\n width={\"100%\"}\n gap={3}\n className=\"oui-auto-rows-fr\"\n style={{\n height: props.containerSize?.height,\n }}\n >\n <Flex\n direction={\"column\"}\n itemAlign={\"start\"}\n // pl={3}\n pt={3}\n pb={3}\n r=\"2xl\"\n className=\"oui-bg-base-9\"\n >\n <Title title=\"Order book\" className=\"oui-pl-3\" />\n <OrderBookWidget\n symbol={props.symbol}\n height={\n props.containerSize\n ? props.containerSize.height - 29 - 24\n : undefined\n }\n />\n </Flex>\n <Flex\n direction={\"column\"}\n itemAlign={\"start\"}\n p={3}\n r=\"2xl\"\n className=\"oui-bg-base-9 oui-h-full\"\n >\n <Title title=\"Last trades\" />\n <LastTradesWidget\n symbol={props.symbol}\n style={{\n height: props.containerSize && props.containerSize.height - 29 - 24,\n }}\n />\n </Flex>\n </Grid>\n );\n};\nconst TabLayout: FC<OrderBookAndTradesState> = (props) => {\n return (\n <Box\n // pl={3}\n pt={3}\n pb={3}\n pr={props.tab === \"lastTrades\" ? 3 : 0}\n r=\"2xl\"\n className=\"oui-bg-base-9\"\n style={{\n maxHeight: props.containerSize?.height,\n }}\n >\n <Tabs\n value={props.tab}\n variant=\"contained\"\n onValueChange={(tab) => {\n props.setTab(tab as any);\n }}\n >\n <TabPanel value=\"orderBook\" title={\"Order book\"} >\n <OrderBookWidget\n symbol={props.symbol}\n height={\n props.containerSize\n ? props.containerSize.height - 29 - 18\n : undefined\n }\n />\n </TabPanel>\n <TabPanel value=\"lastTrades\" title={\"Last trades\"}>\n <LastTradesWidget\n symbol={props.symbol}\n style={{\n height: props.containerSize && props.containerSize.height - 29 - 18,\n }}\n />\n </TabPanel>\n </Tabs>\n </Box>\n );\n};\n\nconst Title = (props: { title: string; className?: string }) => {\n return (\n <Text size=\"base\" intensity={80} className={cn(\"oui-pb-[5px]\",props.className)}>\n {props.title}\n </Text>\n );\n};\n","import { useEffect, useRef, useState } from \"react\";\n\nexport const useOrderBookAndTradesScript = (symbol: string) => {\n const [containerSize, setContainerSize] = useState<\n | {\n width: number;\n height: number;\n }\n | undefined\n >(undefined);\n\n const [tab, setTab] = useState<\"orderBook\" | \"lastTrades\">(\"orderBook\");\n\n const containerRef = useRef<HTMLDivElement>();\n\n useEffect(() => {\n const resizeObserver = new ResizeObserver((entries) => {\n for (let entry of entries) {\n const { width, height } = entry.contentRect;\n setContainerSize({\n width,\n height,\n });\n }\n });\n\n const targetDiv = containerRef.current;\n\n if (targetDiv) {\n resizeObserver.observe(targetDiv);\n }\n\n return () => {\n if (targetDiv) {\n resizeObserver.unobserve(targetDiv);\n }\n };\n }, []);\n\n return {\n symbol,\n containerSize,\n containerRef: containerRef as any,\n tab,setTab,\n };\n};\n\nexport type OrderBookAndTradesState = ReturnType<\n typeof useOrderBookAndTradesScript\n>;\n","import { useOrderBookAndTradesScript } from \"./orderBookAndTrades.script\";\nimport { OrderBookAndTrades } from \"./orderBookAndTrades.ui\";\n\nexport const OrderBookAndTradesWidget = (props: {\n symbol: string;\n}) => {\n const state = useOrderBookAndTradesScript(props.symbol);\n return (<OrderBookAndTrades {...state} />);\n};\n","import { FC } from \"react\";\nimport { Box, Flex, Text } from \"@orderly.network/ui\";\nimport { TradingV2State } from \"./tradingV2.script\";\nimport { DataListWidget } from \"../components/dataList\";\nimport { TradingviewWidget } from \"@orderly.network/ui-tradingview\";\nimport { LastTradesWidget } from \"../components/lastTrades\";\nimport { AssetViewWidget } from \"../components/assetView\";\nimport { RiskRateWidget } from \"../components/riskRate\";\nimport { OrderBookAndTradesWidget } from \"../components/orderBookAndTrades\";\n\nexport const TradingV2: FC<TradingV2State> = (props) => {\n return (\n <Flex direction={\"column\"} gap={3} p={3} className=\"oui-bg-base-10\">\n <Flex p={3} width={\"100%\"} height={600} gap={3}>\n <Box className=\"oui-flex-1\" width={\"100%\"} height={\"100%\"}>\n <TradingviewWidget\n symbol={props.symbol}\n libraryPath={props.tradingViewConfig?.library_path}\n scriptSRC={props.tradingViewConfig?.scriptSRC}\n customCssUrl={props.tradingViewConfig?.customCssUrl}\n />\n </Box>\n <Box className=\"oui-flex-1\" width={\"100%\"} height={\"100%\"}>\n <OrderBookAndTradesWidget symbol={props.symbol} />\n </Box>\n </Flex>\n <Box className=\"oui-bg-base-9 oui-rounded-2xl oui-p-3\">\n <DataListWidget {...props.dataList} />\n </Box>\n\n <Box className=\"oui-bg-base-9 oui-rounded-2xl oui-p-3 oui-space-y-8 oui-w-full\">\n <AssetViewWidget />\n </Box>\n\n <Box className=\"oui-bg-base-9 oui-rounded-2xl oui-p-3 oui-space-y-8 oui-w-full\">\n <RiskRateWidget />\n </Box>\n </Flex>\n );\n};\n","import { createContext, PropsWithChildren, useContext } from \"react\";\nimport { useSymbolsInfo, utils } from \"@orderly.network/hooks\";\nimport { TradingPageState, TradingPageV2Props } from \"../types/types\";\nimport { API } from \"@orderly.network/types\";\nimport { getBasicSymbolInfo } from \"../utils/utils\";\n\nexport const TradingPageContext = createContext({} as TradingPageState);\nexport const useTradingPateContext = () => {\n return useContext(TradingPageContext);\n};\n\nexport const TradingPageProvider = (\n props: PropsWithChildren<TradingPageV2Props>\n) => {\n const symbolInfo = useSymbolsInfo()[props.symbol];\n\n console.log(\"trading page provider\", props, \"symbol info\", symbolInfo);\n \n\n return (\n <TradingPageContext.Provider\n value={{\n ...props,\n symbolInfo: {\n ...(getBasicSymbolInfo(symbolInfo)),\n symbol: props.symbol,\n },\n }}\n >\n {props.children}\n </TradingPageContext.Provider>\n );\n};\n\n","import { useTradingPateContext } from \"../provider/context\";\nimport { TradingPageV2Props } from \"../types/types\";\n\nexport const useTradingV2Script = () => {\n const props = useTradingPateContext();\n return props;\n};\n\nexport type TradingV2State = ReturnType<typeof useTradingV2Script>;\n","import { TradingPageV2Props } from \"../types/types\";\nimport { useTradingV2Script } from \"./tradingV2.script\";\nimport { TradingV2 } from \"./tradingV2.ui\";\n\nexport const TradingV2Widget = () => {\n const state = useTradingV2Script();\n return (<TradingV2 {...state} />);\n};\n","import { TradingPageProvider } from \"../provider\";\nimport { TradingPageV2Props } from \"../types/types\";\nimport { TradingV2Widget } from \"./tradingV2.widget\";\n\nexport const TradingPageV2 = (props: TradingPageV2Props) => {\n return (\n <TradingPageProvider\n symbol={props.symbol}\n tradingViewConfig={props.tradingViewConfig}\n onSymbolChange={props.onSymbolChange}\n disableFeatures={props.disableFeatures}\n overrideFeatures={props.overrideFeatures}\n dataList={props.dataList}\n >\n <TradingV2Widget />\n </TradingPageProvider>\n );\n};\n"]}