1(this["webpackJsonphollaex-kit"]=this["webpackJsonphollaex-kit"]||[]).push([[108],{3466:function(e,t,a){"use strict";a.r(t);var l=a(0),r=a.n(l),n=(a(5),a(23)),o=a.n(n),c=a(133),s=a(1377),i=a(278),m=a(1387),p=a(342),u=a(1290),y=a(226),d=a(1376),b=a(225),E=a(71),g=a(1390),h=a(25),v=a(13),w=a(24);const{Option:S}=c.a,{Text:O}=s.a;t.default=Object(h.connect)(e=>({pairs:e.app.pairs,coins:e.app.coins,constants:e.app.constants,transaction_limits:e.app.transaction_limits,balance:e.user.balance,user:e.user,p2p_config:e.app.constants.p2p_config}))(Object(v.e)(Object(w.a)(e=>{let{coins:t,pairs:a,constants:n={},icons:s,user:h,token:v,balance:w}=e;const[C,k]=Object(l.useState)(),[j,f]=Object(l.useState)(""),[_,x]=Object(l.useState)(!0),[I,M]=Object(l.useState)(""),[T,B]=Object(l.useState)(""),[P,z]=Object(l.useState)(),[F,A]=Object(l.useState)("buy"),[D,L]=Object(l.useState)(""),[q,J]=Object(l.useState)("market"),[N,U]=Object(l.useState)(""),[V,Z]=Object(l.useState)(""),[G,H]=Object(l.useState)(""),[K,Q]=Object(l.useState)(w),[R,W]=Object(l.useState)([]);Object(l.useEffect)(()=>{X()},[]);const X=async()=>{try{const e=await o.a.get("/margin/position");W(e.data.data),Y()}catch(a){var e,t;i.b.error("Error fetching margin positions: "+((null===(e=a.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.message)||a.message))}},Y=async()=>{try{const e=await o.a.get("/user/balance");Q(e.data)}catch(e){return e}},$=e=>{let{title:t,data:a}=e;return r.a.createElement("div",{style:{width:"100%"}},r.a.createElement(O,{strong:!0,style:{color:"#bfbfbf",marginBottom:12,display:"block"}},t),r.a.createElement(p.a,{gutter:[24,8]},Object.entries(a).map(e=>{let[t,a]=e;return r.a.createElement(y.a,{span:8,key:t},r.a.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},r.a.createElement(O,{style:{color:"#8c8c8c"}},t,":"),r.a.createElement(O,{style:{color:"#f5f5f5"}},a)))})))};return r.a.createElement("div",{className:"summary-container"},r.a.createElement("div",{style:{padding:"24px"}},r.a.createElement("h1",{style:{color:"white"}},"Margin Trading"),(()=>{delete K.user_id;const e=Object.keys(K).reduce((e,t)=>{const a=t.match(/^([a-zA-Z]+)_/);if(a){const l=a[1];e[l]||(e[l]={}),e[l][t]=K[t]}return e},{});return r.a.createElement(m.a,{title:"Balance Overview",headStyle:{color:"white",backgroundColor:"#1a1a1a"},style:{backgroundColor:"#262626",color:"white",marginTop:"24px",marginBottom:20,border:"1px solid #404040"}},r.a.createElement(p.a,{gutter:[0,16],style:{padding:16}},Object.keys(e).map(t=>{const{[t+"_margin_balance"]:a,[t+"_margin_available"]:l,[t+"_borrowed"]:n}=e[t];return r.a.createElement(r.a.Fragment,{key:t},r.a.createElement($,{title:t.toUpperCase()+" Balances",data:{"Margin Total Balance":a,"Margin Available Balance":l,"Margin Borrowed":n}}),t!==Object.keys(e).slice(-1)[0]&&r.a.createElement(u.a,{style:{borderColor:"#404040",margin:"16px 0"}}))}),r.a.createElement("div",{style:{marginTop:16,textAlign:"right"}},r.a.createElement(O,{type:"secondary",style:{color:"#8c8c8c",fontSize:12}},"Last Updated: ",new Date(K.timestamp).toLocaleString()))))})(),r.a.createElement(p.a,{gutter:[16,16]},r.a.createElement(y.a,{span:8},r.a.createElement(m.a,{headStyle:{color:"white"},style:{backgroundColor:"#333333",color:"white",border:"1px solid #404040"},title:"Create Margin Transfer"},r.a.createElement(d.a,{style:{color:"white"},layout:"vertical"},r.a.createElement(d.a.Item,{label:r.a.createElement("label",{style:{color:"white"}},"Balance Symbol")},r.a.createElement(c.a,{value:C,onChange:e=>k(e),placeholder:"Select a symbol",style:{width:"100%"}},Object.keys(t).map(e=>r.a.createElement(c.a.Option,{value:e},e)))),r.a.createElement(d.a.Item,{label:r.a.createElement("label",{style:{color:"white"}},"Balance Amount")},r.a.createElement(b.a,{type:"number",value:j,onChange:e=>f(e.target.value),placeholder:"input"})),r.a.createElement(d.a.Item,{label:r.a.createElement("label",{style:{color:"white"}},"Transfer Direction")},r.a.createElement(c.a,{value:_,onChange:e=>x(e)},r.a.createElement(S,{value:!0},"Margin to Spot"),r.a.createElement(S,{value:!1},"Spot to Margin"))),r.a.createElement(E.a,{type:"primary",onClick:async()=>{try{const e=await o.a.post("/margin",{balance_symbol:C,balance_amount:parseFloat(j),margin_to_spot:_});i.b.success("Success: "+e.data.message),X()}catch(l){var e,t,a;i.b.error("Error: "+((null===(e=l.response)||void 0===e||null===(t=e.data)||void 0===t||null===(a=t.message)||void 0===a?void 0:a.message)||l.message))}}},"Create Transfer")))),r.a.createElement(y.a,{span:8}
1,r.a.createElement(m.a,{headStyle:{color:"white"},style:{backgroundColor:"#333333",color:"white",border:"1px solid #404040"},title:"Create Margin Order"},r.a.createElement(d.a,{layout:"vertical"},r.a.createElement(d.a.Item,{label:r.a.createElement("label",{style:{color:"white"}},"Symbol")},r.a.createElement(c.a,{value:P,onChange:e=>z(e),placeholder:"Select a symbol",style:{width:"100%"}},Object.keys(a).map(e=>r.a.createElement(c.a.Option,{value:e},e)))),r.a.createElement(d.a.Item,{label:r.a.createElement("label",{style:{color:"white"}},"Side")},r.a.createElement(c.a,{value:F,onChange:e=>A(e)},r.a.createElement(S,{value:"buy"},"Buy"),r.a.createElement(S,{value:"sell"},"Sell"))),r.a.createElement(d.a.Item,{label:r.a.createElement("label",{style:{color:"white"}},"Size")},r.a.createElement(b.a,{type:"number",value:D,onChange:e=>L(e.target.value),placeholder:"input.1"})),r.a.createElement(d.a.Item,{label:r.a.createElement("label",{style:{color:"white"}},"Type")},r.a.createElement(c.a,{value:q,onChange:e=>J(e)},r.a.createElement(S,{value:"market"},"Market"),r.a.createElement(S,{value:"limit"},"Limit"))),"limit"===q&&r.a.createElement(d.a.Item,{label:r.a.createElement("label",{style:{color:"white"}},"Price")},r.a.createElement(b.a,{type:"number",value:N,onChange:e=>U(e.target.value),placeholder:"input"})),r.a.createElement(E.a,{type:"primary",onClick:async()=>{try{const e=await o.a.post("/order",{symbol:P,side:F,size:parseFloat(D),type:q,price:N?parseFloat(N):void 0,stop:V?parseFloat(V):void 0,meta:{margin:!0}});i.b.success("Success: "+e.data.message),X()}catch(a){var e,t;i.b.error("Error: "+((null===(e=a.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.message)||a.message))}}},"Create Order")))),r.a.createElement(y.a,{span:8},r.a.createElement(m.a,{headStyle:{color:"white"},style:{backgroundColor:"#333333",color:"white",border:"1px solid #404040"},title:"Close Margin Position"},r.a.createElement(d.a,{layout:"vertical"},r.a.createElement(d.a.Item,{label:r.a.createElement("label",{style:{color:"white"}},"Target Asset")},r.a.createElement(c.a,{value:P,onChange:e=>M(e),placeholder:"Select a coin",style:{width:"100%"}},Object.keys(t).map(e=>r.a.createElement(c.a.Option,{value:e},e)))),r.a.createElement(d.a.Item,{label:r.a.createElement("label",{style:{color:"white"}},"Position ID")},r.a.createElement(b.a,{type:"number",value:T,onChange:e=>B(e.target.value),placeholder:"input"})),r.a.createElement(E.a,{type:"primary",onClick:async()=>{try{const e=await o.a.post("/margin/position",{target_asset:I,position_id:parseFloat(T)});i.b.success("Success: "+e.data.message),X()}catch(a){var e,t;i.b.error("Error: "+((null===(e=a.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.message)||a.message))}}},"Close Position"))))),r.a.createElement(m.a,{headStyle:{color:"white"},style:{backgroundColor:"#333333",color:"white",marginTop:"24px",border:"1px solid #404040"},title:"Margin Positions"},R.length>0?r.a.createElement(g.b,{dataSource:R,renderItem:e=>r.a.createElement(g.b.Item,null,r.a.createElement(m.a,{headStyle:{color:"white"},title:"Position ID: "+e.id,style:{width:"100%",backgroundColor:"#333333",border:"1px solid #404040"}},r.a.createElement(p.a,{gutter:[16,16]},r.a.createElement(y.a,{span:8},r.a.createElement("p",{style:{color:"white"}},r.a.createElement("strong",{style:{color:"white "}},"Symbol:")," ",e.symbol),r.a.createElement("p",{style:{color:"white"}},r.a.createElement("strong",{style:{color:"white "}},"Side:")," ",e.side),r.a.createElement("p",{style:{color:"white"}},r.a.createElement("strong",{style:{color:"white "}},"Size:")," ",e.size),r.a.createElement("p",{style:{color:"white"}},r.a.createElement("strong",{style:{color:"white "}},"Value:")," ",e.value)),r.a.createElement(y.a,{span:8},r.a.createElement("p",{style:{color:"white"}},r.a.createElement("strong",{style:{color:"white "}},"Open Price:")," ",e.open_price),r.a.createElement("p",{style:{color:"white"}},r.a.createElement("strong",{style:{color:"white "}},"Current Price:")," ",e.current_price),r.a.createElement("p",{style:{color:"white"}},r.a.createElement("strong",{style:{color:"white "}},"Liquidation Price:")," ",e.liquidation_price)))))}):r.a.createElement("p",{style:{color:"white"}}
1,"No margin positions found."))))})))}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.