@dodoex/widgets 3.14.1-react.1 → 3.14.1-react.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/assets/bundle-BBymdwHN.css +65 -0
- package/dist/{helper-CQ8Clocj.js → helper-5M79rMcu.js} +1 -1
- package/dist/{helper-Dzp_C5O7.cjs → helper-BjErvAPT.cjs} +1 -1
- package/dist/index-CfUamTLh.cjs +78 -0
- package/dist/index-CzGOlGFO.cjs +12 -0
- package/dist/index-DDvJb4bR.cjs +14 -0
- package/dist/index-DG3l6Gjm.js +14 -0
- package/dist/index-DXkJy6xu.js +78 -0
- package/dist/index-waICfk4T.js +12 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/assets/bundle-DSSoJu9z.css +0 -297
- package/dist/index-BV7yhAFZ.cjs +0 -78
- package/dist/index-CM1znFdK.cjs +0 -12
- package/dist/index-CWlMhnOc.js +0 -40
- package/dist/index-CdnUu5l1.js +0 -12
- package/dist/index-Ci_MIjDG.js +0 -78
- package/dist/index-rXrwk4Lb.cjs +0 -40
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import e from"bignumber.js";import{merge as t,throttle as i,debounce as o}from"lodash";import{useEffect as r,useMemo as n,useRef as l,useState as a}from"react";import{BiChevronLeft as s,BiMinus as d,BiPlus as p,BiChevronRight as u}from"react-icons/bi";import m from"@emotion/styled";import{css as c}from"@emotion/react";import{Stage as g,Layer as h,Rect as b,Line as M,Text as f,Circle as v,Label as P,Tag as x}from"react-konva";import{c as y,e as L,a as z,b as w,d as k,f as B,u as C,l as S,g as X,h as q,i as A,j as T,k as N}from"./helper-5M79rMcu.js";import{f as W,a as F,b as j}from"./index-DG3l6Gjm.js";import{jsxs as Z,jsx as G}from"react/jsx-runtime";import{solveQuadraticFunctionForTarget as H,PMMModel as E}from"@dodoex/api";import"@lingui/core";import"@dodoex/components";import"@dodoex/dodo-contract-request";import"@babel/runtime/helpers/interopRequireDefault";import"@babel/runtime/helpers/defineProperty";import"@lingui/react";import"identicon.js";import"zustand";import"zustand/middleware";import"@web3-react/core";import"@web3-react/eip1193";import"@web3-react/walletconnect-v2";import"@web3-react/metamask";import"@web3-react/types";import"@tanstack/react-query";import"@ethersproject/bignumber";import"react-dom";import"react-window";import"dayjs";import"dayjs/plugin/utc";import"dayjs/plugin/duration";import"dayjs/plugin/localizedFormat";import"react-transition-group";import"react-is";import"@dodoex/contract-request";import"axios";import"recharts";import"react-dom/client";import"jsbi";import"tiny-invariant";import"@uniswap/sdk-core";import"@uniswap/v2-sdk";import"react-infinite-scroller";import"d3";import"rmc-date-picker";import"rmc-date-picker/assets/index.css";import"react-datetime/css/react-datetime.css";const J=m.input`
|
|
2
|
+
margin: 4px 10px 4px 6px;
|
|
3
|
+
border-radius: 10px;
|
|
4
|
+
border: 1px solid #373739;
|
|
5
|
+
padding: 4px 9px;
|
|
6
|
+
background-color: #1a1a1b;
|
|
7
|
+
color: #ffffff;
|
|
8
|
+
font-size: 14px;
|
|
9
|
+
font-weight: 400;
|
|
10
|
+
line-height: 20px;
|
|
11
|
+
outline: none;
|
|
12
|
+
width: 96px;
|
|
13
|
+
&:focus {
|
|
14
|
+
border-color: #fff;
|
|
15
|
+
|
|
16
|
+
${({error:e})=>e&&c`
|
|
17
|
+
border-color: red;
|
|
18
|
+
`}
|
|
19
|
+
}
|
|
20
|
+
`;const D="rgba(38, 39, 41, 0.3)";function Y({width:o,height:a,midPrice:s,pmmModel:d,params:p,baseTokenSymbol:u,quoteTokenSymbol:m,baseMinAndZoomMultiples:c,colorMap:A,setBaseMinAndZoomMultiples:T}){const N=t({grid:"#2A2A2D",midPriceLine:"#313335",leftBg:[0,D,1,"#31645d"],leftLine:"#55f6db",leftColor:"",rightBg:[0,D,1,"#67303d"],rightLine:"#ff4f73",rightColor:"",tooltipBg:"#121212",tooltipColor:void 0},A),F=o,j=a-18,H=F/7,{buyBaseVert:E,sellBaseVert:J}=z({midPrice:s,q:p.q,q0:p.q0,pmmModel:d}),Y=E.div(j),V=J.div(j),R=l(null),I=l(null),{current:$}=R,O=l(0),Q=l(),{horizontalGridLines:K,verticalGridLines:U}=function({chartHeight:e,chartWidth:t,horizontalLineCount:i,verticalLineCount:o}){return n(()=>{const r=[],n=e/(i+1),l=[],a=t/o;for(let e=0;e<i;e++){const i=n*(e+1);r.push([0,i,t,i])}for(let t=0;t<o;t++){const i=a*t+a/2;l.push([i,0,i,e])}return{horizontalGridLines:r,verticalGridLines:l}},[e,t,i,o])}({chartHeight:j,chartWidth:F,horizontalLineCount:9,verticalLineCount:7}),{horizontalLabelTickPoints:_,horizontalLabelTextPoints:ee}=function({chartHeight:e,chartWidth:t,xAxisPoints:i,oneXPx:o,baseMinAndZoomMultiples:r}){return n(()=>{const n=y(t,r.zoomMultiples),l=[],a=[];for(let t=0;t<i;t++){l.push([t*o+o/2,e,t*o+o/2,e+4]);const i=n.multipliedBy(t).multipliedBy(o).plus(n.multipliedBy(o/2)).toNumber(),s=r.baseMin.multipliedBy(10**i),d=t*o,p=e+2+4,u=W(s);a.push({x:d,y:p,text:u})}return{horizontalLabelTickPoints:l,horizontalLabelTextPoints:a}},[r.baseMin,r.zoomMultiples,e,t,o,i])}({chartHeight:j,chartWidth:F,xAxisPoints:7,oneXPx:H,baseMinAndZoomMultiples:c}),{quoteLinePoints:te,quoteLineAreaPoints:ie,quoteLineAreaLinearGradientEndPointY:oe,baseLinePoints:re,baseLineAreaPoints:ne,baseLineAreaLinearGradientEndPointY:le,midPriceLinePoints:ae}=function({chartHeight:t,chartWidth:i,midPrice:o,xPoints:r,pmmModel:l,baseMinAndZoomMultiples:a,buyYPortion:s,sellYPortion:d}){return n(()=>{const n=[],p=[],u=[],{baseMin:m,zoomMultiples:c}=a,g=y(i,c),h=2*c,b=new e(h).div(r);let M=new e(Math.log(o.div(m).toNumber())/Math.log(10));M=e.minimum(h,M),M=e.maximum(0,M);for(let i=new e(0);i.lte(M);){const e=m.multipliedBy(10**i.toNumber()),o=L({val:e,model:l});if(!o.vert.isNaN()){const e=i.div(g).toNumber(),r=t-o.vert.div(s).toNumber();n.push(e,r)}i=i.plus(b)}for(let e=M;e.lte(h);){const i=m.multipliedBy(10**e.toNumber()),o=L({val:i,model:l});if(!o.vert.isNaN()){const i=e.div(g).toNumber(),r=t-o.vert.div(d).toNumber();p.push(i,r)}e=e.plus(b)}const f=M.div(g).toNumber(),[,v]=n,P=l.k.eq(0);P&&n.push(f,v||t),n.push(f,t),u.push(f,t,f,0);const x=L({val:m.multipliedBy(10**h),model:l});let z=t;const w=new e(h).div(g).toNumber();return x.vert.isNaN()||(z=t-x.vert.div(d).toNumber()),P&&p.length>=2&&(p.unshift(f,z),p.unshift(f,t)),p.push(w,z),M.lte(0)&&p.unshift(0,t),{quoteLinePoints:n,quoteLineAreaPoints:[0,t,0,v,...n],quoteLineAreaLinearGradientEndPointY:v,baseLinePoints:p,baseLineAreaPoints:[...p,w,t],baseLineAreaLinearGradientEndPointY:z,midPriceLinePoints:u}},[a,i,r,o,l,t,s,d])}({chartHeight:j,chartWidth:F,midPrice:s,xPoints:50,pmmModel:d,baseMinAndZoomMultiples:c,buyYPortion:Y,sellYPortion:V}),se=e=>{var t;const i=e.target;if(i&&$){const e=null===(t=i.getStage())||void 0===t?void 0:t.getPointerPosition();if(e){const{x:t}=e;if(t>F)return void $.hide();C({x:t,tooltip:$,buyBaseVert:E,sellBaseVert:J,chartWidth:F,chartHeight:j,midPrice:s,pmmModel:d,baseTokenSymbol:u,quoteTokenSymbol:m,baseMinAndZoomMultiples:c,t:q,isHover:!0,color:N.tooltipColor,leftColor:N.leftLine,rightColor:N.rightLine})}}},de=n(()=>i(e=>{const{target:t}=e,i=t.getStage();if(i){i.container().style.cursor="grabbing";const e=null==i?void 0:i.getPointerPosition();if(e){const t=e.x-O.current;O.current=e.x,Q.current=e.x,T(e=>void 0===e.baseMin?e:{baseMin:w({dragDistance:t,prevBaseMin:e.baseMin,chartWidth:F,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:0})}}},100),[F,T]),pe=n(()=>i(e=>{e.cancelBubble=!0,e.evt.preventDefault();const t=e.evt.deltaY<0;T(e=>{const i=k({zoomIn:t,prevZoomMultiples:e.zoomMultiples});return{baseMin:B({midPrice:s,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:e.targetMarginPriceX}})},100),[s,T]);return r(()=>{c.targetMarginPriceX>0&&null!==$?C({x:c.targetMarginPriceX,tooltip:$,buyBaseVert:E,sellBaseVert:J,chartWidth:F,chartHeight:j,midPrice:s,pmmModel:d,baseTokenSymbol:u,quoteTokenSymbol:m,baseMinAndZoomMultiples:c,t:q,color:N.tooltipColor,leftColor:N.leftLine,rightColor:N.rightLine}):void 0!==Q.current&&null!==$&&C({x:Q.current,tooltip:$,buyBaseVert:E,sellBaseVert:J,chartWidth:F,chartHeight:j,midPrice:s,pmmModel:d,baseTokenSymbol:u,quoteTokenSymbol:m,baseMinAndZoomMultiples:c,t:q,isHover:!0,color:N.tooltipColor,leftColor:N.leftLine,rightColor:N.rightLine})},[c,u,E,j,F,N.leftLine,N.rightLine,N.tooltipColor,s,d,m,J,$]),Z(g,{ref:I,width:o,offsetY:-X,height:a+X,draggable:!0,dragBoundFunc:function(){return{x:this.absolutePosition().x,y:this.absolutePosition().y}},onMouseMove:se,onMouseOver:se,onMouseOut:()=>{$&&$.hide()},onDragStart:function(e){const{target:t}=e,i=t.getStage();if(i){const e=i.getPointerPosition();e&&(O.current=e.x)}},onDragMove:de,onDragEnd:e=>{const{target:t}=e,i=t.getStage();i&&(i.container().style.cursor="pointer")},onWheel:pe,children:[Z(h,{children:[G(b,{x:0,y:0,width:o,height:j,stroke:N.grid,strokeWidth:1}),K.map((e,t)=>G(M,{points:e,stroke:N.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t)),U.map((e,t)=>G(M,{points:e,stroke:N.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t)),_.map((e,t)=>G(M,{points:e,stroke:"#9d9d9d",strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t)),ee.map((e,t)=>G(f,{x:e.x,y:e.y,text:e.text,fontFamily:"Manrope",fontSize:12,fill:"#9d9d9d",width:H,padding:0,align:"center",verticalAlign:"bottom",listening:!1},t)),G(M,{points:ie,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:j},fillLinearGradientEndPoint:{x:0,y:oe},fillLinearGradientColorStops:N.leftBg}),G(M,{points:te,stroke:N.leftLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),G(M,{points:ne,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:F,y:j},fillLinearGradientEndPoint:{x:F,y:le},fillLinearGradientColorStops:N.rightBg}),G(M,{points:re,stroke:N.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),G(M,{points:ae,stroke:N.midPriceLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]}),Z(h,{ref:R,visible:!1,listening:!1,children:[G(M,{points:[],stroke:"#ff4f73",strokeWidth:1,lineCap:"round",lineJoin:"round",dash:[4,6],id:"toolTipVertLine"}),G(M,{points:[],stroke:"ff4f73",strokeWidth:1,lineCap:"round",lineJoin:"round",dash:[4,6],id:"toolTipHoriLine"}),G(v,{x:0,y:0,radius:5,fill:"#FF5072",stroke:"rgba(255, 80, 114, 0.3)",strokeWidth:12,id:"joinCircle"}),Z(P,{x:0,y:0,id:"priceTextLabel",children:[G(x,{fill:N.tooltipBg,id:"priceTextLabel-tag"}),G(f,{text:"",fontSize:12,fontFamily:"Manrope",padding:4,fill:"#FF5072",id:"priceTextLabel-text"})]}),Z(P,{x:0,y:0,id:"slippageTextLabel",children:[G(x,{fill:N.tooltipBg,id:"slippageTextLabel-tag"}),G(f,{text:"",fontSize:12,fontFamily:"Manrope",padding:4,fill:"#FF5072",id:"slippageTextLabel-text"})]}),Z(P,{x:0,y:0,id:"toolTip",children:[G(x,{fill:N.tooltipBg,pointerDirection:"down",pointerWidth:15,pointerHeight:8,cornerRadius:8,lineJoin:"round",id:"toolTip-tag"}),G(f,{text:"-",fontSize:12,lineHeight:17/12,padding:S,fontFamily:"Manrope",fill:"#FFFFFF",id:"toolTip-text"})]})]})]})}const V=m.button`
|
|
21
|
+
margin: 0;
|
|
22
|
+
border: none;
|
|
23
|
+
padding: 0;
|
|
24
|
+
background: none;
|
|
25
|
+
|
|
26
|
+
&:focus {
|
|
27
|
+
outline: none;
|
|
28
|
+
}
|
|
29
|
+
&:active {
|
|
30
|
+
outline: none;
|
|
31
|
+
}
|
|
32
|
+
`,R=m.div`
|
|
33
|
+
height: 100%;
|
|
34
|
+
`,I=m.div`
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
`,$=m.div`
|
|
38
|
+
border: 1px solid ${({borderColor:e})=>e||"#2a2a2d"};
|
|
39
|
+
flex: 1 0 50%;
|
|
40
|
+
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
font-size: 12px;
|
|
45
|
+
font-weight: 400;
|
|
46
|
+
line-height: 17px;
|
|
47
|
+
color: #606066;
|
|
48
|
+
|
|
49
|
+
& + & {
|
|
50
|
+
border-left: none;
|
|
51
|
+
}
|
|
52
|
+
`,O=m.span`
|
|
53
|
+
color: #85858d;
|
|
54
|
+
`,Q=m.div`
|
|
55
|
+
margin-top: 20px;
|
|
56
|
+
display: flex;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
margin-bottom: 9px;
|
|
59
|
+
`,K=m(V)`
|
|
60
|
+
border-radius: 13px;
|
|
61
|
+
background-color: #373739;
|
|
62
|
+
width: 24px;
|
|
63
|
+
height: 24px;
|
|
64
|
+
font-size: 18px;
|
|
65
|
+
color: #85858d;
|
|
66
|
+
line-height: 0;
|
|
67
|
+
& + & {
|
|
68
|
+
margin-left: 10px;
|
|
69
|
+
}
|
|
70
|
+
&:first-child,
|
|
71
|
+
&:last-child {
|
|
72
|
+
font-size: 20px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&:hover {
|
|
76
|
+
color: #fff;
|
|
77
|
+
}
|
|
78
|
+
`;function U({params:t,target:i,isBuy:o=!0}){const r=new e(t.b),n=new e(t.q);let l=new e(t.b0);const a=new e(t.q0),s=new e(t.i),d=new e(t.k),{R:p}=t;1===p&&l.eq(r)&&(l=H(r,n.minus(a),new e(1).div(s),d));const u=o?r.plus(i):r.minus(i);if(u.lt(l)||r.eq(l)){let t=l.multipliedBy(l).div(u).div(u);return t=new e(1).minus(d).plus(d.multipliedBy(t)),s.multipliedBy(t)}const m=new E;m.RStatus=p,m.B=r,m.B0=l,m.Q=n,m.Q0=a,m.i=s,m.k=d,m.mtFeeRate=new e(0),m.lpFeeRate=new e(0);let c=new e(0);c=o?m.querySellBase(i):m.queryBuyBase(i);const g=o?n.minus(c):n.plus(c);let h=a.multipliedBy(a).div(g).div(g);return h=new e(1).minus(d).plus(d.multipliedBy(h)),s.div(h)}const _=({chartId:t,width:i=834,height:l=460,baseTokenSymbol:m,quoteTokenSymbol:c,pmmModel:g,pmmParams:h,midPrice:b=new e(0),colorMap:M,notShowAmountInput:f})=>{(({id:e})=>{r(()=>{function t(e){e.preventDefault()}let i=!1;try{const e={get passive(){return i=!0,!1}};window.addEventListener("test",()=>{},e),window.removeEventListener("test",()=>{})}catch(e){i=!1}const o=document.getElementById(e),r=!!i&&{passive:!1};return null==o||o.addEventListener("wheel",t,r),()=>{null==o||o.removeEventListener("wheel",t)}},[e])})({id:t});const[v,P]=a(""),[x,y]=a(""),[L,z]=a("-"),[C,S]=a("-"),[X,W]=a({baseMin:new e(0),zoomMultiples:A,targetMarginPriceX:0});r(()=>{void 0!==b&&W(e=>({baseMin:B({midPrice:b,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:e.targetMarginPriceX}))},[b]);const H=n(()=>o(({type:t,amount:o})=>{""===o&&b&&(W({baseMin:B({midPrice:b,zoomMultiples:A}),zoomMultiples:A,targetMarginPriceX:0}),"buy"===t?z("-"):S("-"));const r=new e(o);if(!r.lte(0)&&!r.isNaN()&&(null==h?void 0:h.b)&&!r.gte(h.b)&&b)if("buy"===t){const e=U({params:h,target:r});W(o=>{const r=T({currentBaseMinAndZoomMultiples:o,targetPrice:e,midPrice:b,width:i});if(r.isSkip)return{baseMin:o.baseMin,zoomMultiples:o.zoomMultiples,targetMarginPriceX:r.targetX};if(r.targetX>0)return{baseMin:r.baseMin,zoomMultiples:r.zoomMultiples,targetMarginPriceX:r.targetX};const n=N({midPrice:b,width:i,type:t,targetPrice:e}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:B({midPrice:b,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}}),z(`${F({input:e.minus(b).div(b)})}`)}else{const e=function({params:e,target:t}){return U({params:e,target:t,isBuy:!1})}({params:h,target:r});W(o=>{const r=T({currentBaseMinAndZoomMultiples:o,targetPrice:e,midPrice:b,width:i});if(r.isSkip)return{baseMin:o.baseMin,zoomMultiples:o.zoomMultiples,targetMarginPriceX:r.targetX};if(r.targetX>0)return{baseMin:r.baseMin,zoomMultiples:r.zoomMultiples,targetMarginPriceX:r.targetX};const n=N({midPrice:b,width:i,type:t,targetPrice:e}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:B({midPrice:b,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}}),S(`+${F({input:e.minus(b).div(b)})}`)}},300),[h,b,i]);r(()=>{void 0!==v&&H({type:"buy",amount:v})},[H,v]),r(()=>{void 0!==x&&H({type:"sell",amount:x})},[H,x]);const E=e=>{let t=0;t=e?-.1*i:.1*i,W(e=>void 0===e.baseMin?e:{baseMin:w({dragDistance:t,prevBaseMin:e.baseMin,chartWidth:i,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:e.targetMarginPriceX})},D=e=>{W(t=>{const i=k({zoomIn:null!=e&&e,prevZoomMultiples:t.zoomMultiples});return{baseMin:B({midPrice:b,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:t.targetMarginPriceX}})},V=n(()=>{if(""===v)return!1;const t=new e(v);return!(!t.lte(0)&&!t.isNaN()&&(null==h?void 0:h.b)&&!t.gte(h.b))},[v,h]),_=n(()=>{if(""===x)return!1;const t=new e(x);return!(!t.lte(0)&&!t.isNaN()&&(null==h?void 0:h.b)&&!t.gte(h.b))},[x,h]);return Z(R,{id:t,children:[f?"":Z(I,{children:[Z($,{borderColor:M&&M.grid,children:[q("pool.chart.buy-amount",{symbol:m}),G(J,{value:v,error:V,onChange:e=>{const t=j(e.target.value,2);null!==t&&P(t)}}),G(O,{children:q("pool.chart.price-impact",{amount:L})})]}),Z($,{borderColor:M&&M.grid,children:[q("pool.chart.sell-amount",{symbol:m}),G(J,{value:x,error:_,onChange:e=>{const t=j(e.target.value,2);null!==t&&y(t)}}),G(O,{children:q("pool.chart.price-impact",{amount:C})})]})]}),void 0!==h&&void 0!==b&&void 0!==g&&void 0!==X.baseMin&&void 0!==b&&G(Y,{width:i,height:l,params:h,midPrice:b,pmmModel:g,baseTokenSymbol:m,quoteTokenSymbol:c,baseMinAndZoomMultiples:X,colorMap:M,setBaseMinAndZoomMultiples:W}),Z(Q,{className:"operate-btn-wrapper",children:[G(K,{onClick:()=>E(!0),children:G(s,{})}),G(K,{onClick:()=>D(!1),children:G(d,{})}),G(K,{onClick:()=>D(!0),children:G(p,{})}),G(K,{onClick:()=>E(!1),children:G(u,{})})]})]})};export{_ as default};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import t from"@emotion/styled";import{merge as e}from"lodash";import{useMemo as i,useRef as n}from"react";import{l as r,h as o,m as l}from"./helper-5M79rMcu.js";import{Line as a,Text as s,Stage as d,Layer as m,Rect as p,Circle as g,Label as u,Tag as c}from"react-konva";import{f as h}from"./index-DG3l6Gjm.js";import f from"bignumber.js";import{jsxs as x,Fragment as L,jsx as b}from"react/jsx-runtime";import{solveQuadraticFunctionForTarget as w,PMMState as A,PMMHelper as y}from"@dodoex/api";import"@lingui/core";import"@dodoex/components";import"@dodoex/dodo-contract-request";import"@babel/runtime/helpers/interopRequireDefault";import"@babel/runtime/helpers/defineProperty";import"@lingui/react";import"identicon.js";import"zustand";import"zustand/middleware";import"@web3-react/core";import"@web3-react/eip1193";import"@web3-react/walletconnect-v2";import"@web3-react/metamask";import"@web3-react/types";import"@tanstack/react-query";import"@ethersproject/bignumber";import"react-dom";import"react-window";import"dayjs";import"dayjs/plugin/utc";import"dayjs/plugin/duration";import"dayjs/plugin/localizedFormat";import"react-transition-group";import"react-is";import"@dodoex/contract-request";import"axios";import"recharts";import"react-dom/client";import"jsbi";import"tiny-invariant";import"@uniswap/sdk-core";import"@uniswap/v2-sdk";import"react-infinite-scroller";import"d3";import"rmc-date-picker";import"rmc-date-picker/assets/index.css";import"react-datetime/css/react-datetime.css";const P=t.div`
|
|
2
|
+
height: 100%;
|
|
3
|
+
position: relative;
|
|
4
|
+
`,N=t.div`
|
|
5
|
+
text-align: center;
|
|
6
|
+
margin-top: 17.1px;
|
|
7
|
+
margin-bottom: 88.41px;
|
|
8
|
+
color: #606066;
|
|
9
|
+
font-size: 12px;
|
|
10
|
+
line-height: 17px;
|
|
11
|
+
font-weight: 400;
|
|
12
|
+
`;function v({maxHeight:t,gridAreaHeight:e,value:i}){const n=new f(e).minus(36),r=n.div(t);return n.minus(i.multipliedBy(r)).plus(36).toNumber()}function H({targetPrice:t,areaPoints:e,isLeft:i}){for(let n=0;n<e.length;n++){const r=e[n],o=n<e.length-1?e[n+1]:null;if(!o)return{targetAreaStatPoint:r,targetAreaStatPoints:e};if(i){if(t.lte(r.middlePrice)&&t.gte(o.middlePrice))return{targetAreaStatPoint:r,targetAreaStatPoints:e.slice(0,n+1)}}else if(t.gte(r.middlePrice)&&t.lte(o.middlePrice))return{targetAreaStatPoint:r,targetAreaStatPoints:e.slice(0,n+1)}}return{targetAreaStatPoint:null,targetAreaStatPoints:[]}}function S({x:t,width:e,minXLN10:i,maxXLN10:n}){const r=new f(t).div(e).multipliedBy(n.minus(i)).plus(i);return new f(10**r.toNumber())}function k({width:t,targetLN10:e,minXLN10:i,maxXLN10:n}){return e.minus(i).div(n.minus(i)).multipliedBy(t).toNumber()}function X({target:t}){return new f(Math.log10(t.toNumber()))}const B="rgba(38, 39, 41, 0.3)";function C({width:t,height:P,params:N,baseTokenSymbol:C,quoteTokenSymbol:M,colorMap:W}){const{maxLeftHeight:F,maxRightHeight:T,leftStatAreaPoints:j,rightStatAreaPoints:q,minXLN10:J,maxXLN10:R}=function({params:t}){return i(()=>{const e=new f(t.b),i=new f(t.q);let n=new f(t.b0);const r=new f(t.q0),o=new f(t.i),l=new f(t.k),{R:a}=t;1===a&&n.eq(e)&&(n=w(e,i.minus(r),new f(1).div(o),l));const s=new A({i:o,K:l,B:e,Q:i,B0:n,Q0:r,R:a,mtFeeRate:new f(0),lpFeeRate:new f(0)}),d=new y,m=new f(s.B),p=[],g=[];let u=new f(0),c=new f(0);const h=d.GetMidPrice(s),x=i.gt(0)?e.div(i):new f(1);for(let t=0;t<=250;t++){let e=m.multipliedBy(t/100).multipliedBy(h.multipliedBy(x).multipliedBy(4));0===t&&(e=m.multipliedBy(1e-11));const i=null==d?void 0:d.QuerySellBase(e,s);if(!i.isNaN()&&i.gt(0)){const t=i.div(e);p.push({giveAmount:e,getAmount:i,price:t});continue}p.push({giveAmount:e,getAmount:new f(0),price:new f(0)})}for(let t=0;t<=250;t++){let e=m.multipliedBy(t/100).multipliedBy(h.multipliedBy(4));0===t&&(e=m.multipliedBy(1e-11));const i=null==d?void 0:d.QuerySellQuote(e,s);if(!i.isNaN()&&i.gt(0)){const t=e.dividedBy(i);g.push({giveAmount:e,getAmount:i,price:t});continue}g.push({giveAmount:e,getAmount:new f(0),price:new f(0)})}if(p.length<2&&g.length<2)return{leftStatAreaPoints:[],rightStatAreaPoints:[],maxLeftHeight:new f(10).multipliedBy(1.2),maxRightHeight:new f(10).multipliedBy(1.2),middlePriceLN10:new f(0),minXLN10:new f(-1),maxXLN10:new f(1)};const L=[];for(let t=1;t<p.length;t++){const e=p[t],{giveAmount:i,getAmount:n,price:r}=e,o=p[t-1];if(!r.isNaN()&&r.gt(0)&&o){const e=r.minus(o.price).abs(),l=i.minus(o.giveAmount).abs(),a=n.minus(o.getAmount).abs().multipliedBy(l);1===t&&L.push({area:n,price:r,middlePrice:r.plus(e.div(1.1)),rectangleHeight:a.plus(a.multipliedBy(.03))}),L.push({area:n,price:r,middlePrice:r.plus(e.div(2)),rectangleHeight:a}),u=f.max(a,u)}}const b=[];for(let t=1;t<g.length;t++){const e=g[t],{giveAmount:i,getAmount:n,price:r}=e,o=g[t-1],l=o.price,a=o.giveAmount,s=o.getAmount;if(!r.isNaN()&&r.gt(0)&&o){const e=r.minus(l).abs(),o=i.minus(a).abs(),d=n.minus(s).abs().multipliedBy(o);1===t&&b.push({area:n,price:r,middlePrice:r.minus(e.div(1.1)),rectangleHeight:d.plus(d.multipliedBy(.03))}),b.push({area:n,price:r,middlePrice:r.minus(e.div(2)),rectangleHeight:d}),c=f.max(d,c)}}const P=p.length>0?p[p.length-1]:g[0],N=g.length>0?g[0]:p[0],v=g.length>0?g[g.length-1]:p[0],H=P.price,S=v.price,k=N.price,X=new f(Math.log10(k.toNumber()));let B=H.gt(0)?new f(Math.log10(H.toNumber())):new f(-Math.log10(S.toNumber())),C=S.gt(0)?new f(Math.log10(S.toNumber())):new f(-Math.log10(H.toNumber()));const M=f.max(X.minus(B).abs(),C.minus(X).abs());return B=X.minus(M),C=X.plus(M),{leftStatAreaPoints:L,rightStatAreaPoints:b,maxLeftHeight:u.multipliedBy(1.2),maxRightHeight:c.multipliedBy(1.2),minXLN10:B,maxXLN10:C,middlePriceLN10:X}},[t])}({params:N}),O=P-30.13,z=n(null),D=e({grid:"#2A2A2D",midPriceLine:"#313335",leftBg:[0,B,1,"#31645d"],leftLine:"#55f6db",leftColor:"",rightBg:[0,B,1,"#67303d"],rightLine:"#ff4f73",rightColor:"",tooltipBg:"#121212",tooltipColor:void 0,textColor:"#606066"},W),G=e=>{var i;const{current:n}=z,r=e.target;if(r&&n){const e=null===(i=r.getStage())||void 0===i?void 0:i.getPointerPosition();if(e){const{x:i}=e,r=t/2;if(Math.abs(i-r)<=2)return;if(i<=2||t-i<=2)return;const a=S({x:i,width:t,minXLN10:J,maxXLN10:R});let s=null,d=[];const m=i<r;if(m){const t=H({areaPoints:j,targetPrice:a,isLeft:m});s=t.targetAreaStatPoint,d=t.targetAreaStatPoints}else{const t=H({areaPoints:q,targetPrice:a,isLeft:m});s=t.targetAreaStatPoint,d=t.targetAreaStatPoints}if(s){const e=X({target:s.middlePrice}),r=k({minXLN10:J,maxXLN10:R,width:t,targetLN10:e}),a=v({maxHeight:m?F:T,gridAreaHeight:O,value:s.rectangleHeight}),p=n.findOne("#tooltip"),g=n.findOne("#toolTipVertLine"),u=n.findOne("#joinCircle"),c=n.findOne("#tooltip-Text"),f=n.findOne("#tooltip-tag"),x=n.findOne("#priceTextLabel"),L=null==x?void 0:x.findOne("#priceTextLabel-text"),b=n.findOne("#area");null==p||p.position({x:r,y:a-5-6}),null==c||c.fill(D.tooltipColor||(m?"#00FAD9":"#FF5072")),null==c||c.text(m?o("pool.chart.liquidity-chart-buy",{amount:h(s.area),symbol:C,price:h(s.price)}):o("pool.chart.liquidity-chart-sell",{amount:h(s.area),symbol:M,price:h(s.price)})),p&&f&&(p.width()/2>i?(f.pointerDirection("left"),f.pointerHeight(15),f.pointerWidth(8),p.offsetX(-11),p.offsetY(-11)):p.width()/2+i>t?(f.pointerDirection("right"),f.pointerHeight(15),f.pointerWidth(8),p.offsetX(11),p.offsetY(-11)):(f.pointerDirection("down"),f.pointerHeight(8),f.pointerWidth(15),p.offsetX(0),p.offsetY(0))),null==g||g.points([r,O,r,a]),null==g||g.stroke(m?"#55f6db":"#ff4f73");let w=m?"rgb(86, 246, 218)":"#FF5072",A=m?"rgba(86, 246, 218, 0.3)":"rgba(255, 80, 114, 0.3)";D.leftLine&&D.rightLine&&(w=m?D.leftLine:D.rightLine,A=m?`rgba(${l(D.leftLine)}, 0.4)`:`rgba(${l(D.rightLine)}, 0.4)`),u&&(u.x(r),u.y(a),u.fill(w),u.stroke(A)),x&&(x.x(r),x.y(O+8.08+1),x.offsetX(x.width()/2),x.x()-x.width()/2<0?x.x(x.width()/2):x.x()+x.width()/2>t?x.x(t-x.width()/2):x.x(i)),L&&(L.fill(D.tooltipColor||(m?"#00FAD9":"#FF5072")),L.text(h(s.price)));const y=[];for(const e of d){const{middlePrice:i,rectangleHeight:n}=e,r=X({target:i}),o=k({minXLN10:J,maxXLN10:R,width:t,targetLN10:r}),l=v({maxHeight:m?F:T,gridAreaHeight:O,value:n});y.push(o,l+1)}const P=y.slice(),[N,H]=P;m?(P.push(r,a),P.push(r,O),P.push(N,O),P.push(N,H)):(P.unshift(N,O),P.unshift(r,O),P.unshift(r,a)),b&&(b.points(P),b.fill(m?D.leftLine||"#2c5b56":D.rightLine||"#7b3a48")),n.show()}}}},Q=function({gridAreaHeight:t,gridAreaWidth:e,horizontalLineCount:n,verticalLineCount:r,color:o="#2A2A2D"}){return i(()=>{const i=[],l=t/(n+1),s=[],d=e/(r+1);for(let t=0;t<n;t++){const n=l*(t+1);i.push([0,n,e,n])}for(let e=0;e<r;e++){const i=d*(e+1);s.push([i,0,i,t])}return x(L,{children:[i.map((t,e)=>b(a,{points:t,stroke:o,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1},e)),s.map((t,e)=>b(a,{points:t,stroke:o,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1},e))]})},[t,e,n,r,o])}({gridAreaHeight:O,gridAreaWidth:t,horizontalLineCount:9,verticalLineCount:7,color:D.grid}),E=function({minXLN10:t,maxXLN10:e,labelCount:n,gridAreaHeight:r,gridAreaWidth:o,color:l="#606066"}){return i(()=>{const i=o/(n+1),d=[],m=[];for(let l=0;l<n;l++){const n=i/2+i*l;d.push({x:n,y:r+10.08+1,text:h(S({x:i*(l+1),width:o,minXLN10:t,maxXLN10:e}))});const a=i*(l+1);m.push([a,r+1,a,r+4+1])}return x(L,{children:[d.map((t,e)=>b(s,{x:t.x,y:t.y,text:t.text,fontSize:14,fontFamily:"Manrope",fill:l,width:i,padding:0,align:"center",verticalAlign:"bottom",listening:!1},e)),m.map((t,e)=>b(a,{points:t,stroke:l,strokeWidth:1,lineCap:"butt",lineJoin:"miter",tension:1,listening:!1},e))]})},[t,e,r,o,n])}({gridAreaHeight:O,gridAreaWidth:t,labelCount:7,minXLN10:J,maxXLN10:R,color:D.textColor}),Y=function({gridAreaHeight:t,gridAreaWidth:e,color:n="#606066"}){return i(()=>{const i=e/2;return b(a,{points:[i,0,i,t-1],stroke:n,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1})},[t,e,n])}({gridAreaHeight:O,gridAreaWidth:t,color:D.midPriceLine}),{leftLine:V,rightLine:$}=function({leftStatAreaPoints:t,rightStatAreaPoints:e,minXLN10:n,maxXLN10:r,maxLeftHeight:o,maxRightHeight:l,gridAreaWidth:s,gridAreaHeight:d,colorMap:m}){return{leftLine:i(()=>{if(t.length<1)return b(L,{});const e=[];let i=d;for(const l of t){const{middlePrice:t,rectangleHeight:a}=l,m=X({target:t}),p=k({minXLN10:n,maxXLN10:r,width:s,targetLN10:m}),g=v({maxHeight:o,gridAreaHeight:d,value:a});e.push(p,g),g<i&&(i=g)}const l=e.slice(),[p,g]=l,u=l[l.length-1],c=l[l.length-2];return l.push(c,u),l.push(c,d),l.push(p,d),l.push(p,g),x(L,{children:[b(a,{points:l,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:d},fillLinearGradientEndPoint:{x:0,y:i},fillLinearGradientColorStops:m.leftBg}),b(a,{points:e,stroke:m.leftLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})},[t,s,n,r,d,o]),rightLine:i(()=>{if(e.length<1)return b(L,{});const t=[];let i=d;for(const o of e){const{middlePrice:e,rectangleHeight:a}=o,m=X({target:e}),p=k({minXLN10:n,maxXLN10:r,width:s,targetLN10:m}),g=v({maxHeight:l,gridAreaHeight:d,value:a});t.push(p,g),g<i&&(i=g)}const o=t.slice(),[p]=o;return o.unshift(p,d),o.unshift(s,d),x(L,{children:[b(a,{points:o,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:d},fillLinearGradientEndPoint:{x:0,y:i},fillLinearGradientColorStops:m.rightBg}),b(a,{points:t,stroke:m.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})},[e,s,n,r,d,l])}}({leftStatAreaPoints:j,rightStatAreaPoints:q,minXLN10:J,maxXLN10:R,maxLeftHeight:F,maxRightHeight:T,gridAreaWidth:t,gridAreaHeight:O,colorMap:D});return x(d,{width:t,height:P,onMouseMove:G,onMouseOver:G,onMouseEnter:G,onMouseOut:()=>{const{current:t}=z;t&&t.hide()},children:[x(m,{children:[b(p,{x:0,y:0,width:t,height:O,stroke:D.grid,strokeWidth:1}),Q,E,V,$,Y]}),x(m,{ref:z,visible:!1,children:[b(a,{points:[],closed:!0,listening:!1,lineCap:"round",lineJoin:"round",id:"area"}),b(a,{points:[],strokeWidth:1,stroke:"#ff4f73",lineJoin:"round",lineCap:"round",dash:[4,6],id:"toolTipVertLine"}),b(g,{x:0,y:0,radius:5,fill:"#FF5072",stroke:"rgba(255, 80, 114, 0.3)",strokeWidth:12,id:"joinCircle"}),x(u,{listening:!1,x:0,y:0,id:"priceTextLabel",children:[b(c,{fill:D.tooltipBg,id:"priceTextLabel-tag"}),b(s,{text:"-",fontSize:14,fontFamily:"Manrope",padding:2,fill:"#FF5072",id:"priceTextLabel-text"})]}),x(u,{listening:!1,id:"tooltip",children:[b(c,{fill:D.tooltipBg,pointerDirection:"down",pointerWidth:15,pointerHeight:8,cornerRadius:8,lineJoin:"round",id:"tooltip-tag"}),b(s,{text:"",fontFamily:"Manrope",fontSize:12,lineHeight:17/12,padding:r,fill:"#FF5072",id:"tooltip-Text"})]})]})]})}const M=({width:t=834,height:e=462,baseTokenSymbol:i,quoteTokenSymbol:n,pmmModel:r,pmmParams:l,midPrice:a,notShowTipText:s,colorMap:d})=>x(P,{children:[void 0!==l&&void 0!==a&&void 0!==r&&void 0!==a&&b(C,{width:t,height:e,params:l,midPrice:a,pmmModel:r,baseTokenSymbol:i,quoteTokenSymbol:n,colorMap:d}),s?"":x(N,{children:["* ",o("pool.chart.liquidity-chart-tip",{baseTokenSymbol:i})]})]});export{M as default};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./index-
|
|
1
|
+
"use strict";var e=require("./index-DDvJb4bR.cjs");require("react-dom/client"),require("react/jsx-runtime"),require("bignumber.js"),require("lodash"),require("@dodoex/components"),require("@dodoex/api"),require("@dodoex/dodo-contract-request"),require("react"),require("@babel/runtime/helpers/interopRequireDefault"),require("@babel/runtime/helpers/defineProperty"),require("@lingui/core"),require("@lingui/react"),require("identicon.js"),require("zustand"),require("zustand/middleware"),require("@web3-react/core"),require("@web3-react/eip1193"),require("@web3-react/walletconnect-v2"),require("@web3-react/metamask"),require("@web3-react/types"),require("@tanstack/react-query"),require("@ethersproject/bignumber"),require("react-dom"),require("react-window"),require("dayjs"),require("dayjs/plugin/utc"),require("dayjs/plugin/duration"),require("dayjs/plugin/localizedFormat"),require("react-transition-group"),require("react-is"),require("@dodoex/contract-request"),require("axios"),require("recharts"),require("jsbi"),require("tiny-invariant"),require("@uniswap/sdk-core"),require("@uniswap/v2-sdk"),require("react-infinite-scroller"),require("d3"),require("rmc-date-picker"),require("rmc-date-picker/assets/index.css"),require("react-datetime/css/react-datetime.css"),exports.AMMV2Create=e.AMMV2Create,exports.AMMV3PositionManage=e.AMMV3PositionManage,exports.AMMV3PositionsView=e.AMMV3PositionsView,exports.AddLiquidityV3=e.AddLiquidityV3,exports.EmptyList=e.EmptyList,exports.FailedList=e.FailedList,exports.InitSwapWidget=e.InitSwapWidget,exports.Message=e.Message,Object.defineProperty(exports,"MetadataFlag",{enumerable:!0,get:function(){return e.MetadataFlag}}),exports.MiningCreate=e.MiningCreate,exports.MiningDetail=e.MiningDetail,exports.MiningList=e.MiningList,Object.defineProperty(exports,"PageType",{enumerable:!0,get:function(){return e.PageType}}),exports.Pool=e.Pool,exports.PoolCreate=e.PoolCreate,exports.PoolDetail=e.PoolDetail,exports.PoolList=e.PoolList,exports.PoolModify=e.PoolModify,exports.PoolOperate=e.PoolOperate,exports.PoolOperateDialog=e.PoolOperateDialog,exports.PoolWidget=e.PoolWidget,exports.Swap=e.Swap,exports.SwapOrderHistory=e.SwapOrderHistory,exports.SwapWidget=e.SwapWidget,exports.TokenCard=e.TokenCard,exports.TokenLogo=e.TokenLogo,exports.TokenPairStatusButton=e.TokenPairStatusButton,exports.TokenStatusButton=e.TokenStatusButton,exports.UnstyleWidget=e.UnstyleWidget,exports.WIDGET_CLASS_NAME=e.WIDGET_CLASS_NAME,exports.WIDGET_MODULE_CLASS_NAME=e.WIDGET_MODULE_CLASS_NAME,exports.Widget=e.Widget,exports.chainListMap=e.chainListMap,exports.formatPercentageNumber=e.formatPercentageNumber,exports.formatReadableNumber=e.formatReadableNumber,exports.formatShortNumber=e.formatShortNumber,exports.formatTokenAmountNumber=e.formatTokenAmountNumber,exports.getEtherscanPage=e.getEtherscanPage,exports.rpcServerMap=e.rpcServerMap,exports.scanUrlDomainMap=e.scanUrlDomainMap,exports.useMessageState=e.useMessageState,exports.usePoolBalanceInfo=e.usePoolBalanceInfo,exports.useRouterStore=e.useRouterStore,exports.useTokenStatus=e.useTokenStatus,exports.useTradeSwapOrderList=e.useTradeSwapOrderList;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{A as AMMV2Create,
|
|
1
|
+
export{A as AMMV2Create,D as AMMV3PositionManage,C as AMMV3PositionsView,B as AddLiquidityV3,K as EmptyList,J as FailedList,I as InitSwapWidget,g as Message,M as MetadataFlag,z as MiningCreate,y as MiningDetail,x as MiningList,c as PageType,m as Pool,o as PoolCreate,q as PoolDetail,n as PoolList,p as PoolModify,v as PoolOperate,t as PoolOperateDialog,P as PoolWidget,j as Swap,k as SwapOrderHistory,S as SwapWidget,G as TokenCard,H as TokenLogo,F as TokenPairStatusButton,T as TokenStatusButton,U as UnstyleWidget,W as WIDGET_CLASS_NAME,h as WIDGET_MODULE_CLASS_NAME,e as Widget,d as chainListMap,a as formatPercentageNumber,N as formatReadableNumber,f as formatShortNumber,O as formatTokenAmountNumber,L as getEtherscanPage,r as rpcServerMap,s as scanUrlDomainMap,i as useMessageState,w as usePoolBalanceInfo,u as useRouterStore,E as useTokenStatus,l as useTradeSwapOrderList}from"./index-DG3l6Gjm.js";import"react-dom/client";import"react/jsx-runtime";import"bignumber.js";import"lodash";import"@dodoex/components";import"@dodoex/api";import"@dodoex/dodo-contract-request";import"react";import"@babel/runtime/helpers/interopRequireDefault";import"@babel/runtime/helpers/defineProperty";import"@lingui/core";import"@lingui/react";import"identicon.js";import"zustand";import"zustand/middleware";import"@web3-react/core";import"@web3-react/eip1193";import"@web3-react/walletconnect-v2";import"@web3-react/metamask";import"@web3-react/types";import"@tanstack/react-query";import"@ethersproject/bignumber";import"react-dom";import"react-window";import"dayjs";import"dayjs/plugin/utc";import"dayjs/plugin/duration";import"dayjs/plugin/localizedFormat";import"react-transition-group";import"react-is";import"@dodoex/contract-request";import"axios";import"recharts";import"jsbi";import"tiny-invariant";import"@uniswap/sdk-core";import"@uniswap/v2-sdk";import"react-infinite-scroller";import"d3";import"rmc-date-picker";import"rmc-date-picker/assets/index.css";import"react-datetime/css/react-datetime.css";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dodoex/widgets",
|
|
3
|
-
"version": "3.14.1-react.
|
|
3
|
+
"version": "3.14.1-react.02",
|
|
4
4
|
"description": "DODO Widgets",
|
|
5
5
|
"source": "src/index.tsx",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"release": "semantic-release",
|
|
24
24
|
"release:local": "np --any-branch --no-cleanup --no-tests",
|
|
25
25
|
"release.npm-publish": "npm publish --access public",
|
|
26
|
-
"release.npm-publish-beta": "npm publish --tag beta",
|
|
26
|
+
"release.npm-publish-beta": "yarn run prerelease && npm publish --tag beta",
|
|
27
27
|
"test": "jest src",
|
|
28
28
|
"test:e2e": "jest e2e"
|
|
29
29
|
},
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
.rmc-date-picker {
|
|
2
|
-
display: -ms-flexbox;
|
|
3
|
-
display: flex;
|
|
4
|
-
-ms-flex-align: center;
|
|
5
|
-
align-items: center;
|
|
6
|
-
padding: 10px 0;
|
|
7
|
-
}
|
|
8
|
-
.rmc-date-picker-item {
|
|
9
|
-
-ms-flex: 1;
|
|
10
|
-
flex: 1;
|
|
11
|
-
text-align: center;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.rmc-picker,
|
|
15
|
-
.rmc-multi-picker {
|
|
16
|
-
height: 238px;
|
|
17
|
-
/*34*7*/
|
|
18
|
-
}
|
|
19
|
-
.rmc-multi-picker {
|
|
20
|
-
display: -webkit-box;
|
|
21
|
-
display: flex;
|
|
22
|
-
-webkit-box-align: center;
|
|
23
|
-
align-items: center;
|
|
24
|
-
}
|
|
25
|
-
.rmc-picker-item {
|
|
26
|
-
font-size: 16px;
|
|
27
|
-
height: 34px;
|
|
28
|
-
line-height: 34px;
|
|
29
|
-
padding: 0 10px;
|
|
30
|
-
white-space: nowrap;
|
|
31
|
-
position: relative;
|
|
32
|
-
overflow: hidden;
|
|
33
|
-
text-overflow: ellipsis;
|
|
34
|
-
color: #9b9b9b;
|
|
35
|
-
width: 100%;
|
|
36
|
-
box-sizing: border-box;
|
|
37
|
-
}
|
|
38
|
-
.rmc-picker {
|
|
39
|
-
display: block;
|
|
40
|
-
position: relative;
|
|
41
|
-
overflow: hidden;
|
|
42
|
-
width: 100%;
|
|
43
|
-
-webkit-box-flex: 1;
|
|
44
|
-
flex: 1;
|
|
45
|
-
text-align: center;
|
|
46
|
-
}
|
|
47
|
-
.rmc-picker-mask {
|
|
48
|
-
position: absolute;
|
|
49
|
-
left: 0;
|
|
50
|
-
top: 0;
|
|
51
|
-
height: 100%;
|
|
52
|
-
margin: 0 auto;
|
|
53
|
-
width: 100%;
|
|
54
|
-
z-index: 3;
|
|
55
|
-
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(255, 255, 255, 0.95)), to(rgba(255, 255, 255, 0.6))), -webkit-gradient(linear, left bottom, left top, from(rgba(255, 255, 255, 0.95)), to(rgba(255, 255, 255, 0.6)));
|
|
56
|
-
background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.6)), linear-gradient(to top, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.6));
|
|
57
|
-
background-position: top, bottom;
|
|
58
|
-
background-size: 100% 204px;
|
|
59
|
-
background-repeat: no-repeat;
|
|
60
|
-
}
|
|
61
|
-
.rmc-picker-content {
|
|
62
|
-
position: absolute;
|
|
63
|
-
left: 0;
|
|
64
|
-
top: 0;
|
|
65
|
-
width: 100%;
|
|
66
|
-
z-index: 1;
|
|
67
|
-
}
|
|
68
|
-
.rmc-picker-indicator {
|
|
69
|
-
box-sizing: border-box;
|
|
70
|
-
width: 100%;
|
|
71
|
-
height: 34px;
|
|
72
|
-
position: absolute;
|
|
73
|
-
left: 0;
|
|
74
|
-
top: 102px;
|
|
75
|
-
z-index: 3;
|
|
76
|
-
border-top: 1PX solid #ddd;
|
|
77
|
-
border-bottom: 1PX solid #ddd;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/*!
|
|
81
|
-
* https://github.com/arqex/react-datetime
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
.rdt {
|
|
85
|
-
position: relative;
|
|
86
|
-
}
|
|
87
|
-
.rdtPicker {
|
|
88
|
-
display: none;
|
|
89
|
-
position: absolute;
|
|
90
|
-
min-width: 250px;
|
|
91
|
-
padding: 4px;
|
|
92
|
-
margin-top: 1px;
|
|
93
|
-
z-index: 99999 !important;
|
|
94
|
-
background: #fff;
|
|
95
|
-
box-shadow: 0 1px 3px rgba(0,0,0,.1);
|
|
96
|
-
border: 1px solid #f9f9f9;
|
|
97
|
-
}
|
|
98
|
-
.rdtOpen .rdtPicker {
|
|
99
|
-
display: block;
|
|
100
|
-
}
|
|
101
|
-
.rdtStatic .rdtPicker {
|
|
102
|
-
box-shadow: none;
|
|
103
|
-
position: static;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.rdtPicker .rdtTimeToggle {
|
|
107
|
-
text-align: center;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.rdtPicker table {
|
|
111
|
-
width: 100%;
|
|
112
|
-
margin: 0;
|
|
113
|
-
}
|
|
114
|
-
.rdtPicker td,
|
|
115
|
-
.rdtPicker th {
|
|
116
|
-
text-align: center;
|
|
117
|
-
height: 28px;
|
|
118
|
-
}
|
|
119
|
-
.rdtPicker td {
|
|
120
|
-
cursor: pointer;
|
|
121
|
-
}
|
|
122
|
-
.rdtPicker td.rdtDay:hover,
|
|
123
|
-
.rdtPicker td.rdtHour:hover,
|
|
124
|
-
.rdtPicker td.rdtMinute:hover,
|
|
125
|
-
.rdtPicker td.rdtSecond:hover,
|
|
126
|
-
.rdtPicker .rdtTimeToggle:hover {
|
|
127
|
-
background: #eeeeee;
|
|
128
|
-
cursor: pointer;
|
|
129
|
-
}
|
|
130
|
-
.rdtPicker td.rdtOld,
|
|
131
|
-
.rdtPicker td.rdtNew {
|
|
132
|
-
color: #999999;
|
|
133
|
-
}
|
|
134
|
-
.rdtPicker td.rdtToday {
|
|
135
|
-
position: relative;
|
|
136
|
-
}
|
|
137
|
-
.rdtPicker td.rdtToday:before {
|
|
138
|
-
content: '';
|
|
139
|
-
display: inline-block;
|
|
140
|
-
border-left: 7px solid transparent;
|
|
141
|
-
border-bottom: 7px solid #428bca;
|
|
142
|
-
border-top-color: rgba(0, 0, 0, 0.2);
|
|
143
|
-
position: absolute;
|
|
144
|
-
bottom: 4px;
|
|
145
|
-
right: 4px;
|
|
146
|
-
}
|
|
147
|
-
.rdtPicker td.rdtActive,
|
|
148
|
-
.rdtPicker td.rdtActive:hover {
|
|
149
|
-
background-color: #428bca;
|
|
150
|
-
color: #fff;
|
|
151
|
-
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
|
152
|
-
}
|
|
153
|
-
.rdtPicker td.rdtActive.rdtToday:before {
|
|
154
|
-
border-bottom-color: #fff;
|
|
155
|
-
}
|
|
156
|
-
.rdtPicker td.rdtDisabled,
|
|
157
|
-
.rdtPicker td.rdtDisabled:hover {
|
|
158
|
-
background: none;
|
|
159
|
-
color: #999999;
|
|
160
|
-
cursor: not-allowed;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.rdtPicker td span.rdtOld {
|
|
164
|
-
color: #999999;
|
|
165
|
-
}
|
|
166
|
-
.rdtPicker td span.rdtDisabled,
|
|
167
|
-
.rdtPicker td span.rdtDisabled:hover {
|
|
168
|
-
background: none;
|
|
169
|
-
color: #999999;
|
|
170
|
-
cursor: not-allowed;
|
|
171
|
-
}
|
|
172
|
-
.rdtPicker th {
|
|
173
|
-
border-bottom: 1px solid #f9f9f9;
|
|
174
|
-
}
|
|
175
|
-
.rdtPicker .dow {
|
|
176
|
-
width: 14.2857%;
|
|
177
|
-
border-bottom: none;
|
|
178
|
-
cursor: default;
|
|
179
|
-
}
|
|
180
|
-
.rdtPicker th.rdtSwitch {
|
|
181
|
-
width: 100px;
|
|
182
|
-
}
|
|
183
|
-
.rdtPicker th.rdtNext,
|
|
184
|
-
.rdtPicker th.rdtPrev {
|
|
185
|
-
font-size: 21px;
|
|
186
|
-
vertical-align: top;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.rdtPrev span,
|
|
190
|
-
.rdtNext span {
|
|
191
|
-
display: block;
|
|
192
|
-
-webkit-touch-callout: none; /* iOS Safari */
|
|
193
|
-
-webkit-user-select: none; /* Chrome/Safari/Opera */
|
|
194
|
-
-khtml-user-select: none; /* Konqueror */
|
|
195
|
-
-moz-user-select: none; /* Firefox */
|
|
196
|
-
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
197
|
-
user-select: none;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.rdtPicker th.rdtDisabled,
|
|
201
|
-
.rdtPicker th.rdtDisabled:hover {
|
|
202
|
-
background: none;
|
|
203
|
-
color: #999999;
|
|
204
|
-
cursor: not-allowed;
|
|
205
|
-
}
|
|
206
|
-
.rdtPicker thead tr:first-of-type th {
|
|
207
|
-
cursor: pointer;
|
|
208
|
-
}
|
|
209
|
-
.rdtPicker thead tr:first-of-type th:hover {
|
|
210
|
-
background: #eeeeee;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
.rdtPicker tfoot {
|
|
214
|
-
border-top: 1px solid #f9f9f9;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
.rdtPicker button {
|
|
218
|
-
border: none;
|
|
219
|
-
background: none;
|
|
220
|
-
cursor: pointer;
|
|
221
|
-
}
|
|
222
|
-
.rdtPicker button:hover {
|
|
223
|
-
background-color: #eee;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.rdtPicker thead button {
|
|
227
|
-
width: 100%;
|
|
228
|
-
height: 100%;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
td.rdtMonth,
|
|
232
|
-
td.rdtYear {
|
|
233
|
-
height: 50px;
|
|
234
|
-
width: 25%;
|
|
235
|
-
cursor: pointer;
|
|
236
|
-
}
|
|
237
|
-
td.rdtMonth:hover,
|
|
238
|
-
td.rdtYear:hover {
|
|
239
|
-
background: #eee;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.rdtCounters {
|
|
243
|
-
display: inline-block;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.rdtCounters > div {
|
|
247
|
-
float: left;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
.rdtCounter {
|
|
251
|
-
height: 100px;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
.rdtCounter {
|
|
255
|
-
width: 40px;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.rdtCounterSeparator {
|
|
259
|
-
line-height: 100px;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
.rdtCounter .rdtBtn {
|
|
263
|
-
height: 40%;
|
|
264
|
-
line-height: 40px;
|
|
265
|
-
cursor: pointer;
|
|
266
|
-
display: block;
|
|
267
|
-
|
|
268
|
-
-webkit-touch-callout: none; /* iOS Safari */
|
|
269
|
-
-webkit-user-select: none; /* Chrome/Safari/Opera */
|
|
270
|
-
-khtml-user-select: none; /* Konqueror */
|
|
271
|
-
-moz-user-select: none; /* Firefox */
|
|
272
|
-
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
273
|
-
user-select: none;
|
|
274
|
-
}
|
|
275
|
-
.rdtCounter .rdtBtn:hover {
|
|
276
|
-
background: #eee;
|
|
277
|
-
}
|
|
278
|
-
.rdtCounter .rdtCount {
|
|
279
|
-
height: 20%;
|
|
280
|
-
font-size: 1.2em;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
.rdtMilli {
|
|
284
|
-
vertical-align: middle;
|
|
285
|
-
padding-left: 8px;
|
|
286
|
-
width: 48px;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.rdtMilli input {
|
|
290
|
-
width: 100%;
|
|
291
|
-
font-size: 1.2em;
|
|
292
|
-
margin-top: 37px;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
.rdtTime td {
|
|
296
|
-
cursor: default;
|
|
297
|
-
}
|
package/dist/index-BV7yhAFZ.cjs
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("bignumber.js"),t=require("lodash"),i=require("react"),r=require("@emotion/styled"),o=require("@emotion/react"),n=require("react-konva"),s=require("./helper-Dzp_C5O7.cjs"),l=require("./index-rXrwk4Lb.cjs"),a=require("@dodoex/api");require("@lingui/core"),require("@dodoex/components"),require("@dodoex/dodo-contract-request"),require("@lingui/react"),require("identicon.js"),require("zustand"),require("@web3-react/core"),require("@web3-react/eip1193"),require("@web3-react/walletconnect-v2"),require("@web3-react/metamask"),require("@web3-react/types"),require("@tanstack/react-query"),require("@ethersproject/bignumber"),require("react-dom"),require("react-window"),require("dayjs"),require("react-transition-group"),require("@dodoex/contract-request"),require("axios"),require("recharts"),require("jsbi"),require("tiny-invariant"),require("@uniswap/sdk-core"),require("@uniswap/v2-sdk"),require("react-infinite-scroller"),require("d3"),require("rmc-date-picker");var u={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},c=i.createContext&&i.createContext(u),d=["attr","size","title"];function p(e,t){if(null==e)return{};var i,r,o=function(e,t){if(null==e)return{};var i={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;i[r]=e[r]}return i}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(r=0;r<n.length;r++)i=n[r],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i])}return o}function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},m.apply(this,arguments)}function x(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,r)}return i}function g(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?x(Object(i),!0).forEach(function(t){h(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):x(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function h(e,t,i){var r;return(t="symbol"==typeof(r=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?r:r+"")in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function f(e){return e&&e.map((e,t)=>i.createElement(e.tag,g({key:t},e.attr),f(e.child)))}function b(e){return t=>i.createElement(M,m({attr:g({},e.attr)},t),f(e.child))}function M(e){var t=t=>{var r,{attr:o,size:n,title:s}=e,l=p(e,d),a=n||t.size||"1em";return t.className&&(r=t.className),e.className&&(r=(r?r+" ":"")+e.className),i.createElement("svg",m({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,o,l,{className:r,style:g(g({color:e.color||t.color},t.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),s&&i.createElement("title",null,s),e.children)};return void 0!==c?i.createElement(c.Consumer,null,e=>t(e)):t(u)}function v(e){return b({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M13.293 6.293 7.586 12l5.707 5.707 1.414-1.414L10.414 12l4.293-4.293z"},child:[]}]})(e)}function y(e){return b({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10.707 17.707 16.414 12l-5.707-5.707-1.414 1.414L13.586 12l-4.293 4.293z"},child:[]}]})(e)}function j(e){return b({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M5 11h14v2H5z"},child:[]}]})(e)}function P(e){return b({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z"},child:[]}]})(e)}const L=r.input`
|
|
2
|
-
margin: 4px 10px 4px 6px;
|
|
3
|
-
border-radius: 10px;
|
|
4
|
-
border: 1px solid #373739;
|
|
5
|
-
padding: 4px 9px;
|
|
6
|
-
background-color: #1a1a1b;
|
|
7
|
-
color: #ffffff;
|
|
8
|
-
font-size: 14px;
|
|
9
|
-
font-weight: 400;
|
|
10
|
-
line-height: 20px;
|
|
11
|
-
outline: none;
|
|
12
|
-
width: 96px;
|
|
13
|
-
&:focus {
|
|
14
|
-
border-color: #fff;
|
|
15
|
-
|
|
16
|
-
${({error:e})=>e&&o.css`
|
|
17
|
-
border-color: red;
|
|
18
|
-
`}
|
|
19
|
-
}
|
|
20
|
-
`;const w="rgba(38, 39, 41, 0.3)";function E({width:r,height:o,midPrice:a,pmmModel:u,params:c,baseTokenSymbol:d,quoteTokenSymbol:p,baseMinAndZoomMultiples:m,colorMap:x,setBaseMinAndZoomMultiples:g}){const h=t.merge({grid:"#2A2A2D",midPriceLine:"#313335",leftBg:[0,w,1,"#31645d"],leftLine:"#55f6db",leftColor:"",rightBg:[0,w,1,"#67303d"],rightLine:"#ff4f73",rightColor:"",tooltipBg:"#121212",tooltipColor:void 0},x),f=r,b=o-18,M=f/7,{buyBaseVert:v,sellBaseVert:y}=s.computeBaseVert({midPrice:a,q:c.q,q0:c.q0,pmmModel:u}),j=v.div(b),P=y.div(b),L=i.useRef(null),E=i.useRef(null),{current:z}=L,B=i.useRef(0),q=i.useRef(),{horizontalGridLines:k,verticalGridLines:T}=function({chartHeight:e,chartWidth:t,horizontalLineCount:r,verticalLineCount:o}){return i.useMemo(()=>{const i=[],n=e/(r+1),s=[],l=t/o;for(let e=0;e<r;e++){const r=n*(e+1);i.push([0,r,t,r])}for(let t=0;t<o;t++){const i=l*t+l/2;s.push([i,0,i,e])}return{horizontalGridLines:i,verticalGridLines:s}},[e,t,r,o])}({chartHeight:b,chartWidth:f,horizontalLineCount:9,verticalLineCount:7}),{horizontalLabelTickPoints:R,horizontalLabelTextPoints:C}=function({chartHeight:e,chartWidth:t,xAxisPoints:r,oneXPx:o,baseMinAndZoomMultiples:n}){return i.useMemo(()=>{const i=s.computeXPortion(t,n.zoomMultiples),a=[],u=[];for(let t=0;t<r;t++){a.push([t*o+o/2,e,t*o+o/2,e+4]);const r=i.multipliedBy(t).multipliedBy(o).plus(i.multipliedBy(o/2)).toNumber(),s=n.baseMin.multipliedBy(10**r),c=t*o,d=e+2+4,p=l.formatShortNumber(s);u.push({x:c,y:d,text:p})}return{horizontalLabelTickPoints:a,horizontalLabelTextPoints:u}},[n.baseMin,n.zoomMultiples,e,t,o,r])}({chartHeight:b,chartWidth:f,xAxisPoints:7,oneXPx:M,baseMinAndZoomMultiples:m}),{quoteLinePoints:S,quoteLineAreaPoints:N,quoteLineAreaLinearGradientEndPointY:O,baseLinePoints:A,baseLineAreaPoints:X,baseLineAreaLinearGradientEndPointY:Z,midPriceLinePoints:W}=function({chartHeight:t,chartWidth:r,midPrice:o,xPoints:n,pmmModel:l,baseMinAndZoomMultiples:a,buyYPortion:u,sellYPortion:c}){return i.useMemo(()=>{const i=[],d=[],p=[],{baseMin:m,zoomMultiples:x}=a,g=s.computeXPortion(r,x),h=2*x,f=new e(h).div(n);let b=new e(Math.log(o.div(m).toNumber())/Math.log(10));b=e.minimum(h,b),b=e.maximum(0,b);for(let r=new e(0);r.lte(b);){const e=m.multipliedBy(10**r.toNumber()),o=s.evalPoint({val:e,model:l});if(!o.vert.isNaN()){const e=r.div(g).toNumber(),n=t-o.vert.div(u).toNumber();i.push(e,n)}r=r.plus(f)}for(let e=b;e.lte(h);){const i=m.multipliedBy(10**e.toNumber()),r=s.evalPoint({val:i,model:l});if(!r.vert.isNaN()){const i=e.div(g).toNumber(),o=t-r.vert.div(c).toNumber();d.push(i,o)}e=e.plus(f)}const M=b.div(g).toNumber(),[,v]=i,y=l.k.eq(0);y&&i.push(M,v||t),i.push(M,t),p.push(M,t,M,0);const j=s.evalPoint({val:m.multipliedBy(10**h),model:l});let P=t;const L=new e(h).div(g).toNumber();return j.vert.isNaN()||(P=t-j.vert.div(c).toNumber()),y&&d.length>=2&&(d.unshift(M,P),d.unshift(M,t)),d.push(L,P),b.lte(0)&&d.unshift(0,t),{quoteLinePoints:i,quoteLineAreaPoints:[0,t,0,v,...i],quoteLineAreaLinearGradientEndPointY:v,baseLinePoints:d,baseLineAreaPoints:[...d,L,t],baseLineAreaLinearGradientEndPointY:P,midPriceLinePoints:p}},[a,r,n,o,l,t,u,c])}({chartHeight:b,chartWidth:f,midPrice:a,xPoints:50,pmmModel:u,baseMinAndZoomMultiples:m,buyYPortion:j,sellYPortion:P}),F=e=>{var t;const i=e.target;if(i&&z){const e=null===(t=i.getStage())||void 0===t?void 0:t.getPointerPosition();if(e){const{x:t}=e;if(t>f)return void z.hide();s.updateTooltip({x:t,tooltip:z,buyBaseVert:v,sellBaseVert:y,chartWidth:f,chartHeight:b,midPrice:a,pmmModel:u,baseTokenSymbol:d,quoteTokenSymbol:p,baseMinAndZoomMultiples:m,t:s.chartT,isHover:!0,color:h.tooltipColor,leftColor:h.leftLine,rightColor:h.rightLine})}}},H=i.useMemo(()=>t.throttle(e=>{const{target:t}=e,i=t.getStage();if(i){i.container().style.cursor="grabbing";const e=null==i?void 0:i.getPointerPosition();if(e){const t=e.x-B.current;B.current=e.x,q.current=e.x,g(e=>void 0===e.baseMin?e:{baseMin:s.computeBaseMinByDistance({dragDistance:t,prevBaseMin:e.baseMin,chartWidth:f,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:0})}}},100),[f,g]),D=i.useMemo(()=>t.throttle(e=>{e.cancelBubble=!0,e.evt.preventDefault();const t=e.evt.deltaY<0;g(e=>{const i=s.computeZoomMultiplesWhenZoom({zoomIn:t,prevZoomMultiples:e.zoomMultiples});return{baseMin:s.computeBaseAfterZoom({midPrice:a,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:e.targetMarginPriceX}})},100),[a,g]);return i.useEffect(()=>{m.targetMarginPriceX>0&&null!==z?s.updateTooltip({x:m.targetMarginPriceX,tooltip:z,buyBaseVert:v,sellBaseVert:y,chartWidth:f,chartHeight:b,midPrice:a,pmmModel:u,baseTokenSymbol:d,quoteTokenSymbol:p,baseMinAndZoomMultiples:m,t:s.chartT,color:h.tooltipColor,leftColor:h.leftLine,rightColor:h.rightLine}):void 0!==q.current&&null!==z&&s.updateTooltip({x:q.current,tooltip:z,buyBaseVert:v,sellBaseVert:y,chartWidth:f,chartHeight:b,midPrice:a,pmmModel:u,baseTokenSymbol:d,quoteTokenSymbol:p,baseMinAndZoomMultiples:m,t:s.chartT,isHover:!0,color:h.tooltipColor,leftColor:h.leftLine,rightColor:h.rightLine})},[m,d,v,b,f,h.leftLine,h.rightLine,h.tooltipColor,a,u,p,y,z]),l.jsxRuntimeExports.jsxs(n.Stage,{ref:E,width:r,offsetY:-s.chartOffsetYBCToolTip,height:o+s.chartOffsetYBCToolTip,draggable:!0,dragBoundFunc:function(){return{x:this.absolutePosition().x,y:this.absolutePosition().y}},onMouseMove:F,onMouseOver:F,onMouseOut:()=>{z&&z.hide()},onDragStart:function(e){const{target:t}=e,i=t.getStage();if(i){const e=i.getPointerPosition();e&&(B.current=e.x)}},onDragMove:H,onDragEnd:e=>{const{target:t}=e,i=t.getStage();i&&(i.container().style.cursor="pointer")},onWheel:D,children:[l.jsxRuntimeExports.jsxs(n.Layer,{children:[l.jsxRuntimeExports.jsx(n.Rect,{x:0,y:0,width:r,height:b,stroke:h.grid,strokeWidth:1}),k.map((e,t)=>l.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:h.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t)),T.map((e,t)=>l.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:h.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t)),R.map((e,t)=>l.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:"#9d9d9d",strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t)),C.map((e,t)=>l.jsxRuntimeExports.jsx(n.Text,{x:e.x,y:e.y,text:e.text,fontFamily:"Manrope",fontSize:12,fill:"#9d9d9d",width:M,padding:0,align:"center",verticalAlign:"bottom",listening:!1},t)),l.jsxRuntimeExports.jsx(n.Line,{points:N,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:b},fillLinearGradientEndPoint:{x:0,y:O},fillLinearGradientColorStops:h.leftBg}),l.jsxRuntimeExports.jsx(n.Line,{points:S,stroke:h.leftLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),l.jsxRuntimeExports.jsx(n.Line,{points:X,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:f,y:b},fillLinearGradientEndPoint:{x:f,y:Z},fillLinearGradientColorStops:h.rightBg}),l.jsxRuntimeExports.jsx(n.Line,{points:A,stroke:h.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),l.jsxRuntimeExports.jsx(n.Line,{points:W,stroke:h.midPriceLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]}),l.jsxRuntimeExports.jsxs(n.Layer,{ref:L,visible:!1,listening:!1,children:[l.jsxRuntimeExports.jsx(n.Line,{points:[],stroke:"#ff4f73",strokeWidth:1,lineCap:"round",lineJoin:"round",dash:[4,6],id:"toolTipVertLine"}),l.jsxRuntimeExports.jsx(n.Line,{points:[],stroke:"ff4f73",strokeWidth:1,lineCap:"round",lineJoin:"round",dash:[4,6],id:"toolTipHoriLine"}),l.jsxRuntimeExports.jsx(n.Circle,{x:0,y:0,radius:5,fill:"#FF5072",stroke:"rgba(255, 80, 114, 0.3)",strokeWidth:12,id:"joinCircle"}),l.jsxRuntimeExports.jsxs(n.Label,{x:0,y:0,id:"priceTextLabel",children:[l.jsxRuntimeExports.jsx(n.Tag,{fill:h.tooltipBg,id:"priceTextLabel-tag"}),l.jsxRuntimeExports.jsx(n.Text,{text:"",fontSize:12,fontFamily:"Manrope",padding:4,fill:"#FF5072",id:"priceTextLabel-text"})]}),l.jsxRuntimeExports.jsxs(n.Label,{x:0,y:0,id:"slippageTextLabel",children:[l.jsxRuntimeExports.jsx(n.Tag,{fill:h.tooltipBg,id:"slippageTextLabel-tag"}),l.jsxRuntimeExports.jsx(n.Text,{text:"",fontSize:12,fontFamily:"Manrope",padding:4,fill:"#FF5072",id:"slippageTextLabel-text"})]}),l.jsxRuntimeExports.jsxs(n.Label,{x:0,y:0,id:"toolTip",children:[l.jsxRuntimeExports.jsx(n.Tag,{fill:h.tooltipBg,pointerDirection:"down",pointerWidth:15,pointerHeight:8,cornerRadius:8,lineJoin:"round",id:"toolTip-tag"}),l.jsxRuntimeExports.jsx(n.Text,{text:"-",fontSize:12,lineHeight:17/12,padding:s.labelPadding,fontFamily:"Manrope",fill:"#FFFFFF",id:"toolTip-text"})]})]})]})}const z=r.button`
|
|
21
|
-
margin: 0;
|
|
22
|
-
border: none;
|
|
23
|
-
padding: 0;
|
|
24
|
-
background: none;
|
|
25
|
-
|
|
26
|
-
&:focus {
|
|
27
|
-
outline: none;
|
|
28
|
-
}
|
|
29
|
-
&:active {
|
|
30
|
-
outline: none;
|
|
31
|
-
}
|
|
32
|
-
`,B=r.div`
|
|
33
|
-
height: 100%;
|
|
34
|
-
`,q=r.div`
|
|
35
|
-
display: flex;
|
|
36
|
-
align-items: center;
|
|
37
|
-
`,k=r.div`
|
|
38
|
-
border: 1px solid ${({borderColor:e})=>e||"#2a2a2d"};
|
|
39
|
-
flex: 1 0 50%;
|
|
40
|
-
|
|
41
|
-
display: flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
justify-content: center;
|
|
44
|
-
font-size: 12px;
|
|
45
|
-
font-weight: 400;
|
|
46
|
-
line-height: 17px;
|
|
47
|
-
color: #606066;
|
|
48
|
-
|
|
49
|
-
& + & {
|
|
50
|
-
border-left: none;
|
|
51
|
-
}
|
|
52
|
-
`,T=r.span`
|
|
53
|
-
color: #85858d;
|
|
54
|
-
`,R=r.div`
|
|
55
|
-
margin-top: 20px;
|
|
56
|
-
display: flex;
|
|
57
|
-
justify-content: center;
|
|
58
|
-
margin-bottom: 9px;
|
|
59
|
-
`,C=r(z)`
|
|
60
|
-
border-radius: 13px;
|
|
61
|
-
background-color: #373739;
|
|
62
|
-
width: 24px;
|
|
63
|
-
height: 24px;
|
|
64
|
-
font-size: 18px;
|
|
65
|
-
color: #85858d;
|
|
66
|
-
line-height: 0;
|
|
67
|
-
& + & {
|
|
68
|
-
margin-left: 10px;
|
|
69
|
-
}
|
|
70
|
-
&:first-child,
|
|
71
|
-
&:last-child {
|
|
72
|
-
font-size: 20px;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&:hover {
|
|
76
|
-
color: #fff;
|
|
77
|
-
}
|
|
78
|
-
`;function S({params:t,target:i,isBuy:r=!0}){const o=new e(t.b),n=new e(t.q);let s=new e(t.b0);const l=new e(t.q0),u=new e(t.i),c=new e(t.k),{R:d}=t;1===d&&s.eq(o)&&(s=a.solveQuadraticFunctionForTarget(o,n.minus(l),new e(1).div(u),c));const p=r?o.plus(i):o.minus(i);if(p.lt(s)||o.eq(s)){let t=s.multipliedBy(s).div(p).div(p);return t=new e(1).minus(c).plus(c.multipliedBy(t)),u.multipliedBy(t)}const m=new a.PMMModel;m.RStatus=d,m.B=o,m.B0=s,m.Q=n,m.Q0=l,m.i=u,m.k=c,m.mtFeeRate=new e(0),m.lpFeeRate=new e(0);let x=new e(0);x=r?m.querySellBase(i):m.queryBuyBase(i);const g=r?n.minus(x):n.plus(x);let h=l.multipliedBy(l).div(g).div(g);return h=new e(1).minus(c).plus(c.multipliedBy(h)),u.div(h)}exports.default=({chartId:r,width:o=834,height:n=460,baseTokenSymbol:a,quoteTokenSymbol:u,pmmModel:c,pmmParams:d,midPrice:p=new e(0),colorMap:m,notShowAmountInput:x})=>{(({id:e})=>{i.useEffect(()=>{function t(e){e.preventDefault()}let i=!1;try{const e={get passive(){return i=!0,!1}};window.addEventListener("test",()=>{},e),window.removeEventListener("test",()=>{})}catch(e){i=!1}const r=document.getElementById(e),o=!!i&&{passive:!1};return null==r||r.addEventListener("wheel",t,o),()=>{null==r||r.removeEventListener("wheel",t)}},[e])})({id:r});const[g,h]=i.useState(""),[f,b]=i.useState(""),[M,w]=i.useState("-"),[z,N]=i.useState("-"),[O,A]=i.useState({baseMin:new e(0),zoomMultiples:s.baseZoomMultiples,targetMarginPriceX:0});i.useEffect(()=>{void 0!==p&&A(e=>({baseMin:s.computeBaseAfterZoom({midPrice:p,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:e.targetMarginPriceX}))},[p]);const X=i.useMemo(()=>t.debounce(({type:t,amount:i})=>{""===i&&p&&(A({baseMin:s.computeBaseAfterZoom({midPrice:p,zoomMultiples:s.baseZoomMultiples}),zoomMultiples:s.baseZoomMultiples,targetMarginPriceX:0}),"buy"===t?w("-"):N("-"));const r=new e(i);if(!r.lte(0)&&!r.isNaN()&&(null==d?void 0:d.b)&&!r.gte(d.b)&&p)if("buy"===t){const e=S({params:d,target:r});A(i=>{const r=s.beforePriceImpactEffect({currentBaseMinAndZoomMultiples:i,targetPrice:e,midPrice:p,width:o});if(r.isSkip)return{baseMin:i.baseMin,zoomMultiples:i.zoomMultiples,targetMarginPriceX:r.targetX};if(r.targetX>0)return{baseMin:r.baseMin,zoomMultiples:r.zoomMultiples,targetMarginPriceX:r.targetX};const n=s.computeTargetXByTargetPrice({midPrice:p,width:o,type:t,targetPrice:e}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:s.computeBaseAfterZoom({midPrice:p,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}}),w(`${l.formatPercentageNumber({input:e.minus(p).div(p)})}`)}else{const e=function({params:e,target:t}){return S({params:e,target:t,isBuy:!1})}({params:d,target:r});A(i=>{const r=s.beforePriceImpactEffect({currentBaseMinAndZoomMultiples:i,targetPrice:e,midPrice:p,width:o});if(r.isSkip)return{baseMin:i.baseMin,zoomMultiples:i.zoomMultiples,targetMarginPriceX:r.targetX};if(r.targetX>0)return{baseMin:r.baseMin,zoomMultiples:r.zoomMultiples,targetMarginPriceX:r.targetX};const n=s.computeTargetXByTargetPrice({midPrice:p,width:o,type:t,targetPrice:e}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:s.computeBaseAfterZoom({midPrice:p,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}}),N(`+${l.formatPercentageNumber({input:e.minus(p).div(p)})}`)}},300),[d,p,o]);i.useEffect(()=>{void 0!==g&&X({type:"buy",amount:g})},[X,g]),i.useEffect(()=>{void 0!==f&&X({type:"sell",amount:f})},[X,f]);const Z=e=>{let t=0;t=e?-.1*o:.1*o,A(e=>void 0===e.baseMin?e:{baseMin:s.computeBaseMinByDistance({dragDistance:t,prevBaseMin:e.baseMin,chartWidth:o,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:e.targetMarginPriceX})},W=e=>{A(t=>{const i=s.computeZoomMultiplesWhenZoom({zoomIn:null!=e&&e,prevZoomMultiples:t.zoomMultiples});return{baseMin:s.computeBaseAfterZoom({midPrice:p,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:t.targetMarginPriceX}})},F=i.useMemo(()=>{if(""===g)return!1;const t=new e(g);return!(!t.lte(0)&&!t.isNaN()&&(null==d?void 0:d.b)&&!t.gte(d.b))},[g,d]),H=i.useMemo(()=>{if(""===f)return!1;const t=new e(f);return!(!t.lte(0)&&!t.isNaN()&&(null==d?void 0:d.b)&&!t.gte(d.b))},[f,d]);return l.jsxRuntimeExports.jsxs(B,{id:r,children:[x?"":l.jsxRuntimeExports.jsxs(q,{children:[l.jsxRuntimeExports.jsxs(k,{borderColor:m&&m.grid,children:[s.chartT("pool.chart.buy-amount",{symbol:a}),l.jsxRuntimeExports.jsx(L,{value:g,error:F,onChange:e=>{const t=l.fixedInputStringToFormattedNumber(e.target.value,2);null!==t&&h(t)}}),l.jsxRuntimeExports.jsx(T,{children:s.chartT("pool.chart.price-impact",{amount:M})})]}),l.jsxRuntimeExports.jsxs(k,{borderColor:m&&m.grid,children:[s.chartT("pool.chart.sell-amount",{symbol:a}),l.jsxRuntimeExports.jsx(L,{value:f,error:H,onChange:e=>{const t=l.fixedInputStringToFormattedNumber(e.target.value,2);null!==t&&b(t)}}),l.jsxRuntimeExports.jsx(T,{children:s.chartT("pool.chart.price-impact",{amount:z})})]})]}),void 0!==d&&void 0!==p&&void 0!==c&&void 0!==O.baseMin&&void 0!==p&&l.jsxRuntimeExports.jsx(E,{width:o,height:n,params:d,midPrice:p,pmmModel:c,baseTokenSymbol:a,quoteTokenSymbol:u,baseMinAndZoomMultiples:O,colorMap:m,setBaseMinAndZoomMultiples:A}),l.jsxRuntimeExports.jsxs(R,{className:"operate-btn-wrapper",children:[l.jsxRuntimeExports.jsx(C,{onClick:()=>Z(!0),children:l.jsxRuntimeExports.jsx(v,{})}),l.jsxRuntimeExports.jsx(C,{onClick:()=>W(!1),children:l.jsxRuntimeExports.jsx(j,{})}),l.jsxRuntimeExports.jsx(C,{onClick:()=>W(!0),children:l.jsxRuntimeExports.jsx(P,{})}),l.jsxRuntimeExports.jsx(C,{onClick:()=>Z(!1),children:l.jsxRuntimeExports.jsx(y,{})})]})]})};
|
package/dist/index-CM1znFdK.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("@emotion/styled"),t=require("lodash"),i=require("react"),r=require("./helper-Dzp_C5O7.cjs"),n=require("react-konva"),o=require("./index-rXrwk4Lb.cjs"),s=require("bignumber.js"),l=require("@dodoex/api");require("@lingui/core"),require("@dodoex/components"),require("@dodoex/dodo-contract-request"),require("@lingui/react"),require("identicon.js"),require("zustand"),require("@web3-react/core"),require("@web3-react/eip1193"),require("@web3-react/walletconnect-v2"),require("@web3-react/metamask"),require("@web3-react/types"),require("@tanstack/react-query"),require("@ethersproject/bignumber"),require("react-dom"),require("react-window"),require("dayjs"),require("react-transition-group"),require("@dodoex/contract-request"),require("axios"),require("recharts"),require("jsbi"),require("tiny-invariant"),require("@uniswap/sdk-core"),require("@uniswap/v2-sdk"),require("react-infinite-scroller"),require("d3"),require("rmc-date-picker");const a=e.div`
|
|
2
|
-
height: 100%;
|
|
3
|
-
position: relative;
|
|
4
|
-
`,u=e.div`
|
|
5
|
-
text-align: center;
|
|
6
|
-
margin-top: 17.1px;
|
|
7
|
-
margin-bottom: 88.41px;
|
|
8
|
-
color: #606066;
|
|
9
|
-
font-size: 12px;
|
|
10
|
-
line-height: 17px;
|
|
11
|
-
font-weight: 400;
|
|
12
|
-
`;function d({maxHeight:e,gridAreaHeight:t,value:i}){const r=new s(t).minus(36),n=r.div(e);return r.minus(i.multipliedBy(n)).plus(36).toNumber()}function g({targetPrice:e,areaPoints:t,isLeft:i}){for(let r=0;r<t.length;r++){const n=t[r],o=r<t.length-1?t[r+1]:null;if(!o)return{targetAreaStatPoint:n,targetAreaStatPoints:t};if(i){if(e.lte(n.middlePrice)&&e.gte(o.middlePrice))return{targetAreaStatPoint:n,targetAreaStatPoints:t.slice(0,r+1)}}else if(e.gte(n.middlePrice)&&e.lte(o.middlePrice))return{targetAreaStatPoint:n,targetAreaStatPoints:t.slice(0,r+1)}}return{targetAreaStatPoint:null,targetAreaStatPoints:[]}}function m({x:e,width:t,minXLN10:i,maxXLN10:r}){const n=new s(e).div(t).multipliedBy(r.minus(i)).plus(i);return new s(10**n.toNumber())}function c({width:e,targetLN10:t,minXLN10:i,maxXLN10:r}){return t.minus(i).div(r.minus(i)).multipliedBy(e).toNumber()}function p({target:e}){return new s(Math.log10(e.toNumber()))}const h="rgba(38, 39, 41, 0.3)";function x({width:e,height:a,params:u,baseTokenSymbol:x,quoteTokenSymbol:f,colorMap:L}){const{maxLeftHeight:b,maxRightHeight:j,leftStatAreaPoints:w,rightStatAreaPoints:A,minXLN10:N,maxXLN10:y}=function({params:e}){return i.useMemo(()=>{const t=new s(e.b),i=new s(e.q);let r=new s(e.b0);const n=new s(e.q0),o=new s(e.i),a=new s(e.k),{R:u}=e;1===u&&r.eq(t)&&(r=l.solveQuadraticFunctionForTarget(t,i.minus(n),new s(1).div(o),a));const d=new l.PMMState({i:o,K:a,B:t,Q:i,B0:r,Q0:n,R:u,mtFeeRate:new s(0),lpFeeRate:new s(0)}),g=new l.PMMHelper,m=new s(d.B),c=[],p=[];let h=new s(0),x=new s(0);const f=g.GetMidPrice(d),L=i.gt(0)?t.div(i):new s(1);for(let e=0;e<=250;e++){let t=m.multipliedBy(e/100).multipliedBy(f.multipliedBy(L).multipliedBy(4));0===e&&(t=m.multipliedBy(1e-11));const i=null==g?void 0:g.QuerySellBase(t,d);if(!i.isNaN()&&i.gt(0)){const e=i.div(t);c.push({giveAmount:t,getAmount:i,price:e});continue}c.push({giveAmount:t,getAmount:new s(0),price:new s(0)})}for(let e=0;e<=250;e++){let t=m.multipliedBy(e/100).multipliedBy(f.multipliedBy(4));0===e&&(t=m.multipliedBy(1e-11));const i=null==g?void 0:g.QuerySellQuote(t,d);if(!i.isNaN()&&i.gt(0)){const e=t.dividedBy(i);p.push({giveAmount:t,getAmount:i,price:e});continue}p.push({giveAmount:t,getAmount:new s(0),price:new s(0)})}if(c.length<2&&p.length<2)return{leftStatAreaPoints:[],rightStatAreaPoints:[],maxLeftHeight:new s(10).multipliedBy(1.2),maxRightHeight:new s(10).multipliedBy(1.2),middlePriceLN10:new s(0),minXLN10:new s(-1),maxXLN10:new s(1)};const b=[];for(let e=1;e<c.length;e++){const t=c[e],{giveAmount:i,getAmount:r,price:n}=t,o=c[e-1];if(!n.isNaN()&&n.gt(0)&&o){const t=n.minus(o.price).abs(),l=i.minus(o.giveAmount).abs(),a=r.minus(o.getAmount).abs().multipliedBy(l);1===e&&b.push({area:r,price:n,middlePrice:n.plus(t.div(1.1)),rectangleHeight:a.plus(a.multipliedBy(.03))}),b.push({area:r,price:n,middlePrice:n.plus(t.div(2)),rectangleHeight:a}),h=s.max(a,h)}}const j=[];for(let e=1;e<p.length;e++){const t=p[e],{giveAmount:i,getAmount:r,price:n}=t,o=p[e-1],l=o.price,a=o.giveAmount,u=o.getAmount;if(!n.isNaN()&&n.gt(0)&&o){const t=n.minus(l).abs(),o=i.minus(a).abs(),d=r.minus(u).abs().multipliedBy(o);1===e&&j.push({area:r,price:n,middlePrice:n.minus(t.div(1.1)),rectangleHeight:d.plus(d.multipliedBy(.03))}),j.push({area:r,price:n,middlePrice:n.minus(t.div(2)),rectangleHeight:d}),x=s.max(d,x)}}const w=c.length>0?c[c.length-1]:p[0],A=p.length>0?p[0]:c[0],N=p.length>0?p[p.length-1]:c[0],y=w.price,P=N.price,R=A.price,v=new s(Math.log10(R.toNumber()));let S=y.gt(0)?new s(Math.log10(y.toNumber())):new s(-Math.log10(P.toNumber())),q=P.gt(0)?new s(Math.log10(P.toNumber())):new s(-Math.log10(y.toNumber()));const H=s.max(v.minus(S).abs(),q.minus(v).abs());return S=v.minus(H),q=v.plus(H),{leftStatAreaPoints:b,rightStatAreaPoints:j,maxLeftHeight:h.multipliedBy(1.2),maxRightHeight:x.multipliedBy(1.2),minXLN10:S,maxXLN10:q,middlePriceLN10:v}},[e])}({params:u}),P=a-30.13,R=i.useRef(null),v=t.merge({grid:"#2A2A2D",midPriceLine:"#313335",leftBg:[0,h,1,"#31645d"],leftLine:"#55f6db",leftColor:"",rightBg:[0,h,1,"#67303d"],rightLine:"#ff4f73",rightColor:"",tooltipBg:"#121212",tooltipColor:void 0,textColor:"#606066"},L),S=t=>{var i;const{current:n}=R,s=t.target;if(s&&n){const t=null===(i=s.getStage())||void 0===i?void 0:i.getPointerPosition();if(t){const{x:i}=t,s=e/2;if(Math.abs(i-s)<=2)return;if(i<=2||e-i<=2)return;const l=m({x:i,width:e,minXLN10:N,maxXLN10:y});let a=null,u=[];const h=i<s;if(h){const e=g({areaPoints:w,targetPrice:l,isLeft:h});a=e.targetAreaStatPoint,u=e.targetAreaStatPoints}else{const e=g({areaPoints:A,targetPrice:l,isLeft:h});a=e.targetAreaStatPoint,u=e.targetAreaStatPoints}if(a){const t=p({target:a.middlePrice}),s=c({minXLN10:N,maxXLN10:y,width:e,targetLN10:t}),l=d({maxHeight:h?b:j,gridAreaHeight:P,value:a.rectangleHeight}),g=n.findOne("#tooltip"),m=n.findOne("#toolTipVertLine"),L=n.findOne("#joinCircle"),w=n.findOne("#tooltip-Text"),A=n.findOne("#tooltip-tag"),R=n.findOne("#priceTextLabel"),S=null==R?void 0:R.findOne("#priceTextLabel-text"),q=n.findOne("#area");null==g||g.position({x:s,y:l-5-6}),null==w||w.fill(v.tooltipColor||(h?"#00FAD9":"#FF5072")),null==w||w.text(h?r.chartT("pool.chart.liquidity-chart-buy",{amount:o.formatShortNumber(a.area),symbol:x,price:o.formatShortNumber(a.price)}):r.chartT("pool.chart.liquidity-chart-sell",{amount:o.formatShortNumber(a.area),symbol:f,price:o.formatShortNumber(a.price)})),g&&A&&(g.width()/2>i?(A.pointerDirection("left"),A.pointerHeight(15),A.pointerWidth(8),g.offsetX(-11),g.offsetY(-11)):g.width()/2+i>e?(A.pointerDirection("right"),A.pointerHeight(15),A.pointerWidth(8),g.offsetX(11),g.offsetY(-11)):(A.pointerDirection("down"),A.pointerHeight(8),A.pointerWidth(15),g.offsetX(0),g.offsetY(0))),null==m||m.points([s,P,s,l]),null==m||m.stroke(h?"#55f6db":"#ff4f73");let H=h?"rgb(86, 246, 218)":"#FF5072",E=h?"rgba(86, 246, 218, 0.3)":"rgba(255, 80, 114, 0.3)";v.leftLine&&v.rightLine&&(H=h?v.leftLine:v.rightLine,E=h?`rgba(${r.colorRgb(v.leftLine)}, 0.4)`:`rgba(${r.colorRgb(v.rightLine)}, 0.4)`),L&&(L.x(s),L.y(l),L.fill(H),L.stroke(E)),R&&(R.x(s),R.y(P+8.08+1),R.offsetX(R.width()/2),R.x()-R.width()/2<0?R.x(R.width()/2):R.x()+R.width()/2>e?R.x(e-R.width()/2):R.x(i)),S&&(S.fill(v.tooltipColor||(h?"#00FAD9":"#FF5072")),S.text(o.formatShortNumber(a.price)));const k=[];for(const t of u){const{middlePrice:i,rectangleHeight:r}=t,n=p({target:i}),o=c({minXLN10:N,maxXLN10:y,width:e,targetLN10:n}),s=d({maxHeight:h?b:j,gridAreaHeight:P,value:r});k.push(o,s+1)}const X=k.slice(),[M,B]=X;h?(X.push(s,l),X.push(s,P),X.push(M,P),X.push(M,B)):(X.unshift(M,P),X.unshift(s,P),X.unshift(s,l)),q&&(q.points(X),q.fill(h?v.leftLine||"#2c5b56":v.rightLine||"#7b3a48")),n.show()}}}},q=function({gridAreaHeight:e,gridAreaWidth:t,horizontalLineCount:r,verticalLineCount:s,color:l="#2A2A2D"}){return i.useMemo(()=>{const i=[],a=e/(r+1),u=[],d=t/(s+1);for(let e=0;e<r;e++){const r=a*(e+1);i.push([0,r,t,r])}for(let t=0;t<s;t++){const i=d*(t+1);u.push([i,0,i,e])}return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[i.map((e,t)=>o.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:l,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1},t)),u.map((e,t)=>o.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:l,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1},t))]})},[e,t,r,s,l])}({gridAreaHeight:P,gridAreaWidth:e,horizontalLineCount:9,verticalLineCount:7,color:v.grid}),H=function({minXLN10:e,maxXLN10:t,labelCount:r,gridAreaHeight:s,gridAreaWidth:l,color:a="#606066"}){return i.useMemo(()=>{const i=l/(r+1),u=[],d=[];for(let n=0;n<r;n++){const r=i/2+i*n;u.push({x:r,y:s+10.08+1,text:o.formatShortNumber(m({x:i*(n+1),width:l,minXLN10:e,maxXLN10:t}))});const a=i*(n+1);d.push([a,s+1,a,s+4+1])}return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[u.map((e,t)=>o.jsxRuntimeExports.jsx(n.Text,{x:e.x,y:e.y,text:e.text,fontSize:14,fontFamily:"Manrope",fill:a,width:i,padding:0,align:"center",verticalAlign:"bottom",listening:!1},t)),d.map((e,t)=>o.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:a,strokeWidth:1,lineCap:"butt",lineJoin:"miter",tension:1,listening:!1},t))]})},[e,t,s,l,r])}({gridAreaHeight:P,gridAreaWidth:e,labelCount:7,minXLN10:N,maxXLN10:y,color:v.textColor}),E=function({gridAreaHeight:e,gridAreaWidth:t,color:r="#606066"}){return i.useMemo(()=>{const i=t/2;return o.jsxRuntimeExports.jsx(n.Line,{points:[i,0,i,e-1],stroke:r,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1})},[e,t,r])}({gridAreaHeight:P,gridAreaWidth:e,color:v.midPriceLine}),{leftLine:k,rightLine:X}=function({leftStatAreaPoints:e,rightStatAreaPoints:t,minXLN10:r,maxXLN10:s,maxLeftHeight:l,maxRightHeight:a,gridAreaWidth:u,gridAreaHeight:g,colorMap:m}){return{leftLine:i.useMemo(()=>{if(e.length<1)return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{});const t=[];let i=g;for(const n of e){const{middlePrice:e,rectangleHeight:o}=n,a=p({target:e}),m=c({minXLN10:r,maxXLN10:s,width:u,targetLN10:a}),h=d({maxHeight:l,gridAreaHeight:g,value:o});t.push(m,h),h<i&&(i=h)}const a=t.slice(),[h,x]=a,f=a[a.length-1],L=a[a.length-2];return a.push(L,f),a.push(L,g),a.push(h,g),a.push(h,x),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(n.Line,{points:a,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:g},fillLinearGradientEndPoint:{x:0,y:i},fillLinearGradientColorStops:m.leftBg}),o.jsxRuntimeExports.jsx(n.Line,{points:t,stroke:m.leftLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})},[e,u,r,s,g,l]),rightLine:i.useMemo(()=>{if(t.length<1)return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{});const e=[];let i=g;for(const n of t){const{middlePrice:t,rectangleHeight:o}=n,l=p({target:t}),m=c({minXLN10:r,maxXLN10:s,width:u,targetLN10:l}),h=d({maxHeight:a,gridAreaHeight:g,value:o});e.push(m,h),h<i&&(i=h)}const l=e.slice(),[h]=l;return l.unshift(h,g),l.unshift(u,g),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(n.Line,{points:l,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:g},fillLinearGradientEndPoint:{x:0,y:i},fillLinearGradientColorStops:m.rightBg}),o.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:m.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})},[t,u,r,s,g,a])}}({leftStatAreaPoints:w,rightStatAreaPoints:A,minXLN10:N,maxXLN10:y,maxLeftHeight:b,maxRightHeight:j,gridAreaWidth:e,gridAreaHeight:P,colorMap:v});return o.jsxRuntimeExports.jsxs(n.Stage,{width:e,height:a,onMouseMove:S,onMouseOver:S,onMouseEnter:S,onMouseOut:()=>{const{current:e}=R;e&&e.hide()},children:[o.jsxRuntimeExports.jsxs(n.Layer,{children:[o.jsxRuntimeExports.jsx(n.Rect,{x:0,y:0,width:e,height:P,stroke:v.grid,strokeWidth:1}),q,H,k,X,E]}),o.jsxRuntimeExports.jsxs(n.Layer,{ref:R,visible:!1,children:[o.jsxRuntimeExports.jsx(n.Line,{points:[],closed:!0,listening:!1,lineCap:"round",lineJoin:"round",id:"area"}),o.jsxRuntimeExports.jsx(n.Line,{points:[],strokeWidth:1,stroke:"#ff4f73",lineJoin:"round",lineCap:"round",dash:[4,6],id:"toolTipVertLine"}),o.jsxRuntimeExports.jsx(n.Circle,{x:0,y:0,radius:5,fill:"#FF5072",stroke:"rgba(255, 80, 114, 0.3)",strokeWidth:12,id:"joinCircle"}),o.jsxRuntimeExports.jsxs(n.Label,{listening:!1,x:0,y:0,id:"priceTextLabel",children:[o.jsxRuntimeExports.jsx(n.Tag,{fill:v.tooltipBg,id:"priceTextLabel-tag"}),o.jsxRuntimeExports.jsx(n.Text,{text:"-",fontSize:14,fontFamily:"Manrope",padding:2,fill:"#FF5072",id:"priceTextLabel-text"})]}),o.jsxRuntimeExports.jsxs(n.Label,{listening:!1,id:"tooltip",children:[o.jsxRuntimeExports.jsx(n.Tag,{fill:v.tooltipBg,pointerDirection:"down",pointerWidth:15,pointerHeight:8,cornerRadius:8,lineJoin:"round",id:"tooltip-tag"}),o.jsxRuntimeExports.jsx(n.Text,{text:"",fontFamily:"Manrope",fontSize:12,lineHeight:17/12,padding:r.labelPadding,fill:"#FF5072",id:"tooltip-Text"})]})]})]})}exports.default=({width:e=834,height:t=462,baseTokenSymbol:i,quoteTokenSymbol:n,pmmModel:s,pmmParams:l,midPrice:d,notShowTipText:g,colorMap:m})=>o.jsxRuntimeExports.jsxs(a,{children:[void 0!==l&&void 0!==d&&void 0!==s&&void 0!==d&&o.jsxRuntimeExports.jsx(x,{width:e,height:t,params:l,midPrice:d,pmmModel:s,baseTokenSymbol:i,quoteTokenSymbol:n,colorMap:m}),g?"":o.jsxRuntimeExports.jsxs(u,{children:["* ",r.chartT("pool.chart.liquidity-chart-tip",{baseTokenSymbol:i})]})]});
|