@dodoex/widgets 3.0.2-zetachain.10 → 3.0.2-zetachain.12
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/helper-BnoyRpeK.cjs +561 -0
- package/dist/helper-BnoyRpeK.cjs.map +1 -0
- package/dist/helper-CMiEdcFd.js +545 -0
- package/dist/index-B-5Qs8z3.cjs +1212 -0
- package/dist/index-B-5Qs8z3.cjs.map +1 -0
- package/dist/index-COcquHWW.cjs +974 -0
- package/dist/index-COcquHWW.cjs.map +1 -0
- package/dist/index-CwQNn_Bp.js +1209 -0
- package/dist/index-De8Sa6Av.cjs +96076 -0
- package/dist/index-De8Sa6Av.cjs.map +1 -0
- package/dist/index-bUI_7SKV.js +96014 -0
- package/dist/index-s8jAQFVo.js +971 -0
- package/dist/index.cjs +91 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +37 -1
- package/dist/types/hooks/ConnectWallet/useWalletInfo.d.ts +3 -1
- package/package.json +7 -17
- package/dist/helper-B-L9J5Wk.js +0 -1
- package/dist/helper-DB7pJRlV.cjs +0 -1
- package/dist/index-BGkMyf0r.cjs +0 -78
- package/dist/index-BYYZxbt3.js +0 -263
- package/dist/index-CbzpdArY.cjs +0 -263
- package/dist/index-CnswmG4u.cjs +0 -12
- package/dist/index-D54mvRoh.js +0 -78
- package/dist/index-D8Yofu94.js +0 -12
package/dist/index-CnswmG4u.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("@emotion/styled"),t=require("lodash"),i=require("react"),r=require("./helper-DB7pJRlV.cjs"),n=require("react-konva"),o=require("./index-CbzpdArY.cjs"),s=require("bignumber.js"),l=require("@dodoex/api");require("@lingui/core"),require("@lingui/react"),require("@dodoex/components"),require("@web3-react/core"),require("axios"),require("@ethersproject/bignumber"),require("zustand"),require("@dodoex/dodo-contract-request"),require("@tanstack/react-query"),require("@reown/appkit-utils"),require("@reown/appkit-common"),require("os"),require("events"),require("fs"),require("util"),require("path"),require("worker_threads"),require("module"),require("url"),require("buffer"),require("assert"),require("stream"),require("http"),require("punycode"),require("https"),require("zlib"),require("@web3-react/eip1193"),require("@web3-react/walletconnect-v2"),require("@web3-react/metamask"),require("@web3-react/types"),require("@ethersproject/contracts"),require("identicon.js"),require("react-dom"),require("dayjs"),require("react-transition-group"),require("@dodoex/contract-request"),require("recharts"),require("react-window"),require("jsbi"),require("tiny-invariant"),require("@ethersproject/units"),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
|
-
`,d=36;function m({maxHeight:e,gridAreaHeight:t,value:i}){const r=new s(t).minus(d),n=r.div(e);return r.minus(i.multipliedBy(n)).plus(d).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 p({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 h({target:e}){return new s(Math.log10(e.toNumber()))}const x="rgba(38, 39, 41, 0.3)";function f({width:e,height:a,params:u,baseTokenSymbol:d,quoteTokenSymbol:f,colorMap:L}){const{maxLeftHeight:b,maxRightHeight:j,leftStatAreaPoints:w,rightStatAreaPoints:q,minXLN10:A,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)}),m=new l.PMMHelper,g=new s(d.B),p=[],c=[];let h=new s(0),x=new s(0);const f=m.GetMidPrice(d),L=i.gt(0)?t.div(i):new s(1);for(let e=0;e<=250;e++){let t=g.multipliedBy(e/100).multipliedBy(f.multipliedBy(L).multipliedBy(4));0===e&&(t=g.multipliedBy(1e-11));const i=null==m?void 0:m.QuerySellBase(t,d);if(i.isNaN()||!i.gt(0))p.push({giveAmount:t,getAmount:new s(0),price:new s(0)});else{const e=i.div(t);p.push({giveAmount:t,getAmount:i,price:e})}}for(let e=0;e<=250;e++){let t=g.multipliedBy(e/100).multipliedBy(f.multipliedBy(4));0===e&&(t=g.multipliedBy(1e-11));const i=null==m?void 0:m.QuerySellQuote(t,d);if(i.isNaN()||!i.gt(0))c.push({giveAmount:t,getAmount:new s(0),price:new s(0)});else{const e=t.dividedBy(i);c.push({giveAmount:t,getAmount:i,price:e})}}if(p.length<2&&c.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<p.length;e++){const t=p[e],{giveAmount:i,getAmount:r,price:n}=t,o=p[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<c.length;e++){const t=c[e],{giveAmount:i,getAmount:r,price:n}=t,o=c[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=p.length>0?p[p.length-1]:c[0],q=c.length>0?c[0]:p[0],A=c.length>0?c[c.length-1]:p[0],y=w.price,N=A.price,P=q.price,v=new s(Math.log10(P.toNumber()));let R=y.gt(0)?new s(Math.log10(y.toNumber())):new s(-Math.log10(N.toNumber())),S=N.gt(0)?new s(Math.log10(N.toNumber())):new s(-Math.log10(y.toNumber()));const H=s.max(v.minus(R).abs(),S.minus(v).abs());return R=v.minus(H),S=v.plus(H),{leftStatAreaPoints:b,rightStatAreaPoints:j,maxLeftHeight:h.multipliedBy(1.2),maxRightHeight:x.multipliedBy(1.2),minXLN10:R,maxXLN10:S,middlePriceLN10:v}}),[e])}({params:u}),N=a-30.13,P=i.useRef(null),v=t.merge({grid:"#2A2A2D",midPriceLine:"#313335",leftBg:[0,x,1,"#31645d"],leftLine:"#55f6db",leftColor:"",rightBg:[0,x,1,"#67303d"],rightLine:"#ff4f73",rightColor:"",tooltipBg:"#121212",tooltipColor:void 0,textColor:"#606066"},L),R=t=>{var i;const{current:n}=P,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=p({x:i,width:e,minXLN10:A,maxXLN10:y});let a=null,u=[];const x=i<s;if(x){const e=g({areaPoints:w,targetPrice:l,isLeft:x});a=e.targetAreaStatPoint,u=e.targetAreaStatPoints}else{const e=g({areaPoints:q,targetPrice:l,isLeft:x});a=e.targetAreaStatPoint,u=e.targetAreaStatPoints}if(a){const t=h({target:a.middlePrice}),s=c({minXLN10:A,maxXLN10:y,width:e,targetLN10:t}),l=m({maxHeight:x?b:j,gridAreaHeight:N,value:a.rectangleHeight}),g=n.findOne("#tooltip"),p=n.findOne("#toolTipVertLine"),L=n.findOne("#joinCircle"),w=n.findOne("#tooltip-Text"),q=n.findOne("#tooltip-tag"),P=n.findOne("#priceTextLabel"),R=null==P?void 0:P.findOne("#priceTextLabel-text"),S=n.findOne("#area");null==g||g.position({x:s,y:l-5-6}),null==w||w.fill(v.tooltipColor||(x?"#00FAD9":"#FF5072")),null==w||w.text(x?r.chartT("pool.chart.liquidity-chart-buy",{amount:o.formatShortNumber(a.area),symbol:d,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&&q&&(g.width()/2>i?(q.pointerDirection("left"),q.pointerHeight(15),q.pointerWidth(8),g.offsetX(-11),g.offsetY(-11)):g.width()/2+i>e?(q.pointerDirection("right"),q.pointerHeight(15),q.pointerWidth(8),g.offsetX(11),g.offsetY(-11)):(q.pointerDirection("down"),q.pointerHeight(8),q.pointerWidth(15),g.offsetX(0),g.offsetY(0))),null==p||p.points([s,N,s,l]),null==p||p.stroke(x?"#55f6db":"#ff4f73");let H=x?"rgb(86, 246, 218)":"#FF5072",E=x?"rgba(86, 246, 218, 0.3)":"rgba(255, 80, 114, 0.3)";v.leftLine&&v.rightLine&&(H=x?v.leftLine:v.rightLine,E=x?`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)),P&&(P.x(s),P.y(N+8.08+1),P.offsetX(P.width()/2),P.x()-P.width()/2<0?P.x(P.width()/2):P.x()+P.width()/2>e?P.x(e-P.width()/2):P.x(i)),R&&(R.fill(v.tooltipColor||(x?"#00FAD9":"#FF5072")),R.text(o.formatShortNumber(a.price)));const k=[];for(const t of u){const{middlePrice:i,rectangleHeight:r}=t,n=h({target:i}),o=c({minXLN10:A,maxXLN10:y,width:e,targetLN10:n}),s=m({maxHeight:x?b:j,gridAreaHeight:N,value:r});k.push(o,s+1)}const X=k.slice(),[M,B]=X;x?(X.push(s,l),X.push(s,N),X.push(M,N),X.push(M,B)):(X.unshift(M,N),X.unshift(s,N),X.unshift(s,l)),S&&(S.points(X),S.fill(x?v.leftLine||"#2c5b56":v.rightLine||"#7b3a48")),n.show()}}}},S=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:N,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(p({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:N,gridAreaWidth:e,labelCount:7,minXLN10:A,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:N,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:d,colorMap:g}){return{leftLine:i.useMemo((()=>{if(e.length<1)return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{});const t=[];let i=d;for(const n of e){const{middlePrice:e,rectangleHeight:o}=n,a=h({target:e}),g=c({minXLN10:r,maxXLN10:s,width:u,targetLN10:a}),p=m({maxHeight:l,gridAreaHeight:d,value:o});t.push(g,p),p<i&&(i=p)}const a=t.slice(),[p,x]=a,f=a[a.length-1],L=a[a.length-2];return a.push(L,f),a.push(L,d),a.push(p,d),a.push(p,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:d},fillLinearGradientEndPoint:{x:0,y:i},fillLinearGradientColorStops:g.leftBg}),o.jsxRuntimeExports.jsx(n.Line,{points:t,stroke:g.leftLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})}),[e,u,r,s,d,l]),rightLine:i.useMemo((()=>{if(t.length<1)return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{});const e=[];let i=d;for(const n of t){const{middlePrice:t,rectangleHeight:o}=n,l=h({target:t}),g=c({minXLN10:r,maxXLN10:s,width:u,targetLN10:l}),p=m({maxHeight:a,gridAreaHeight:d,value:o});e.push(g,p),p<i&&(i=p)}const l=e.slice(),[p]=l;return l.unshift(p,d),l.unshift(u,d),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:d},fillLinearGradientEndPoint:{x:0,y:i},fillLinearGradientColorStops:g.rightBg}),o.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:g.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})}),[t,u,r,s,d,a])}}({leftStatAreaPoints:w,rightStatAreaPoints:q,minXLN10:A,maxXLN10:y,maxLeftHeight:b,maxRightHeight:j,gridAreaWidth:e,gridAreaHeight:N,colorMap:v});return o.jsxRuntimeExports.jsxs(n.Stage,{width:e,height:a,onMouseMove:R,onMouseOver:R,onMouseEnter:R,onMouseOut:()=>{const{current:e}=P;e&&e.hide()},children:[o.jsxRuntimeExports.jsxs(n.Layer,{children:[o.jsxRuntimeExports.jsx(n.Rect,{x:0,y:0,width:e,height:N,stroke:v.grid,strokeWidth:1}),S,H,k,X,E]}),o.jsxRuntimeExports.jsxs(n.Layer,{ref:P,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:m,colorMap:g})=>o.jsxRuntimeExports.jsxs(a,{children:[void 0!==l&&void 0!==d&&void 0!==s&&void 0!==d&&o.jsxRuntimeExports.jsx(f,{width:e,height:t,params:l,midPrice:d,pmmModel:s,baseTokenSymbol:i,quoteTokenSymbol:n,colorMap:g}),m?"":o.jsxRuntimeExports.jsxs(u,{children:["* ",r.chartT("pool.chart.liquidity-chart-tip",{baseTokenSymbol:i})]})]});
|
package/dist/index-D54mvRoh.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import t from"bignumber.js";import{merge as e,throttle as i,debounce as o}from"lodash";import r,{useEffect as n,useMemo as l,useRef as s,useState as a}from"react";import d from"@emotion/styled";import{css as u}from"@emotion/react";import{Stage as c,Layer as p,Rect as m,Line as g,Text as h,Circle as b,Label as f,Tag as M}from"react-konva";import{c as v,e as x,a as y,b as P,d as w,f as j,u as z,g as L,h as k,l as B,i as C,j as S,k as N}from"./helper-B-L9J5Wk.js";import{f as O,j as X,a as T,b as A}from"./index-BYYZxbt3.js";import{solveQuadraticFunctionForTarget as q,PMMModel as W}from"@dodoex/api";import"@lingui/core";import"@lingui/react";import"@dodoex/components";import"@web3-react/core";import"axios";import"@ethersproject/bignumber";import"zustand";import"@dodoex/dodo-contract-request";import"@tanstack/react-query";import"@reown/appkit-utils";import"@reown/appkit-common";import"os";import"events";import"fs";import"util";import"path";import"worker_threads";import"module";import"url";import"buffer";import"assert";import"stream";import"http";import"punycode";import"https";import"zlib";import"@web3-react/eip1193";import"@web3-react/walletconnect-v2";import"@web3-react/metamask";import"@web3-react/types";import"@ethersproject/contracts";import"identicon.js";import"react-dom";import"dayjs";import"react-transition-group";import"@dodoex/contract-request";import"recharts";import"react-window";import"jsbi";import"tiny-invariant";import"@ethersproject/units";import"@uniswap/sdk-core";import"@uniswap/v2-sdk";import"react-infinite-scroller";import"d3";import"rmc-date-picker";var E={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},F=r.createContext&&r.createContext(E),H=["attr","size","title"];function Z(t,e){if(null==t)return{};var i,o,r=function(t,e){if(null==t)return{};var i,o,r={},n=Object.keys(t);for(o=0;o<n.length;o++)i=n[o],e.indexOf(i)>=0||(r[i]=t[i]);return r}(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(o=0;o<n.length;o++)i=n[o],e.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(t,i)&&(r[i]=t[i])}return r}function G(){return G=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t},G.apply(this,arguments)}function D(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,o)}return i}function J(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?D(Object(i),!0).forEach((function(e){V(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):D(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function V(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,e||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Y(t){return t&&t.map(((t,e)=>r.createElement(t.tag,J({key:e},t.attr),Y(t.child))))}function I(t){return e=>r.createElement(R,G({attr:J({},t.attr)},e),Y(t.child))}function R(t){var e=e=>{var i,{attr:o,size:n,title:l}=t,s=Z(t,H),a=n||e.size||"1em";return e.className&&(i=e.className),t.className&&(i=(i?i+" ":"")+t.className),r.createElement("svg",G({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},e.attr,o,s,{className:i,style:J(J({color:t.color||e.color},e.style),t.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),l&&r.createElement("title",null,l),t.children)};return void 0!==F?r.createElement(F.Consumer,null,(t=>e(t))):e(E)}function $(t){return I({tag:"svg",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:[]}]})(t)}function Q(t){return I({tag:"svg",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:[]}]})(t)}function _(t){return I({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M5 11h14v2H5z"},child:[]}]})(t)}function K(t){return I({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z"},child:[]}]})(t)}const U=d.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:t})=>t&&u`
|
|
17
|
-
border-color: red;
|
|
18
|
-
`}
|
|
19
|
-
}
|
|
20
|
-
`;const tt="rgba(38, 39, 41, 0.3)";function et({width:o,height:r,midPrice:a,pmmModel:d,params:u,baseTokenSymbol:C,quoteTokenSymbol:S,baseMinAndZoomMultiples:N,colorMap:T,setBaseMinAndZoomMultiples:A}){const q=e({grid:"#2A2A2D",midPriceLine:"#313335",leftBg:[0,tt,1,"#31645d"],leftLine:"#55f6db",leftColor:"",rightBg:[0,tt,1,"#67303d"],rightLine:"#ff4f73",rightColor:"",tooltipBg:"#121212",tooltipColor:void 0},T),W=o,E=r-18,F=W/7,{buyBaseVert:H,sellBaseVert:Z}=y({midPrice:a,q:u.q,q0:u.q0,pmmModel:d}),G=H.div(E),D=Z.div(E),J=s(null),V=s(null),{current:Y}=J,I=s(0),R=s(),{horizontalGridLines:$,verticalGridLines:Q}=function({chartHeight:t,chartWidth:e,horizontalLineCount:i,verticalLineCount:o}){return l((()=>{const r=[],n=t/(i+1),l=[],s=e/o;for(let t=0;t<i;t++){const i=n*(t+1);r.push([0,i,e,i])}for(let e=0;e<o;e++){const i=s*e+s/2;l.push([i,0,i,t])}return{horizontalGridLines:r,verticalGridLines:l}}),[t,e,i,o])}({chartHeight:E,chartWidth:W,horizontalLineCount:9,verticalLineCount:7}),{horizontalLabelTickPoints:_,horizontalLabelTextPoints:K}=function({chartHeight:t,chartWidth:e,xAxisPoints:i,oneXPx:o,baseMinAndZoomMultiples:r}){return l((()=>{const n=v(e,r.zoomMultiples),l=[],s=[];for(let e=0;e<i;e++){l.push([e*o+o/2,t,e*o+o/2,t+4]);const i=n.multipliedBy(e).multipliedBy(o).plus(n.multipliedBy(o/2)).toNumber(),a=r.baseMin.multipliedBy(10**i),d=e*o,u=t+2+4,c=O(a);s.push({x:d,y:u,text:c})}return{horizontalLabelTickPoints:l,horizontalLabelTextPoints:s}}),[r.baseMin,r.zoomMultiples,t,e,o,i])}({chartHeight:E,chartWidth:W,xAxisPoints:7,oneXPx:F,baseMinAndZoomMultiples:N}),{quoteLinePoints:U,quoteLineAreaPoints:et,quoteLineAreaLinearGradientEndPointY:it,baseLinePoints:ot,baseLineAreaPoints:rt,baseLineAreaLinearGradientEndPointY:nt,midPriceLinePoints:lt}=function({chartHeight:e,chartWidth:i,midPrice:o,xPoints:r,pmmModel:n,baseMinAndZoomMultiples:s,buyYPortion:a,sellYPortion:d}){return l((()=>{const l=[],u=[],c=[],{baseMin:p,zoomMultiples:m}=s,g=v(i,m),h=2*m,b=new t(h).div(r);let f=new t(Math.log(o.div(p).toNumber())/Math.log(10));f=t.minimum(h,f),f=t.maximum(0,f);for(let i=new t(0);i.lte(f);){const t=p.multipliedBy(10**i.toNumber()),r=x({val:t,model:n,midPrice:o});if(!r.vert.isNaN()){const t=i.div(g).toNumber(),o=e-r.vert.div(a).toNumber();l.push(t,o)}i=i.plus(b)}for(let t=f;t.lte(h);){const i=p.multipliedBy(10**t.toNumber()),r=x({val:i,model:n,midPrice:o});if(!r.vert.isNaN()){const i=t.div(g).toNumber(),o=e-r.vert.div(d).toNumber();u.push(i,o)}t=t.plus(b)}const M=f.div(g).toNumber(),[,y]=l,P=n.k.eq(0);P&&l.push(M,y||e),l.push(M,e),c.push(M,e,M,0);const w=x({val:p.multipliedBy(10**h),model:n,midPrice:o});let j=e;const z=new t(h).div(g).toNumber();return w.vert.isNaN()||(j=e-w.vert.div(d).toNumber()),P&&u.length>=2&&(u.unshift(M,j),u.unshift(M,e)),u.push(z,j),f.lte(0)&&u.unshift(0,e),{quoteLinePoints:l,quoteLineAreaPoints:[0,e,0,y,...l],quoteLineAreaLinearGradientEndPointY:y,baseLinePoints:u,baseLineAreaPoints:[...u,z,e],baseLineAreaLinearGradientEndPointY:j,midPriceLinePoints:c}}),[s,i,r,o,n,e,a,d])}({chartHeight:E,chartWidth:W,midPrice:a,xPoints:50,pmmModel:d,baseMinAndZoomMultiples:N,buyYPortion:G,sellYPortion:D}),st=t=>{var e;const i=t.target;if(i&&Y){const t=null===(e=i.getStage())||void 0===e?void 0:e.getPointerPosition();if(t){const{x:e}=t;if(e>W)return void Y.hide();z({x:e,tooltip:Y,buyBaseVert:H,sellBaseVert:Z,chartWidth:W,chartHeight:E,midPrice:a,pmmModel:d,baseTokenSymbol:C,quoteTokenSymbol:S,baseMinAndZoomMultiples:N,t:L,isHover:!0,color:q.tooltipColor,leftColor:q.leftLine,rightColor:q.rightLine})}}},at=l((()=>i((t=>{const{target:e}=t,i=e.getStage();if(i){i.container().style.cursor="grabbing";const t=null==i?void 0:i.getPointerPosition();if(t){const e=t.x-I.current;I.current=t.x,R.current=t.x,A((t=>void 0===t.baseMin?t:{baseMin:P({dragDistance:e,prevBaseMin:t.baseMin,chartWidth:W,zoomMultiples:t.zoomMultiples}),zoomMultiples:t.zoomMultiples,targetMarginPriceX:0}))}}}),100)),[W,A]),dt=l((()=>i((t=>{t.cancelBubble=!0,t.evt.preventDefault();const e=t.evt.deltaY<0;A((t=>{const i=w({zoomIn:e,prevZoomMultiples:t.zoomMultiples});return{baseMin:j({midPrice:a,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:t.targetMarginPriceX}}))}),100)),[a,A]);return n((()=>{N.targetMarginPriceX>0&&null!==Y?z({x:N.targetMarginPriceX,tooltip:Y,buyBaseVert:H,sellBaseVert:Z,chartWidth:W,chartHeight:E,midPrice:a,pmmModel:d,baseTokenSymbol:C,quoteTokenSymbol:S,baseMinAndZoomMultiples:N,t:L,color:q.tooltipColor,leftColor:q.leftLine,rightColor:q.rightLine}):void 0!==R.current&&null!==Y&&z({x:R.current,tooltip:Y,buyBaseVert:H,sellBaseVert:Z,chartWidth:W,chartHeight:E,midPrice:a,pmmModel:d,baseTokenSymbol:C,quoteTokenSymbol:S,baseMinAndZoomMultiples:N,t:L,isHover:!0,color:q.tooltipColor,leftColor:q.leftLine,rightColor:q.rightLine})}),[N,C,H,E,W,q.leftLine,q.rightLine,q.tooltipColor,a,d,S,Z,Y]),X.jsxs(c,{ref:V,width:o,offsetY:-k,height:r+k,draggable:!0,dragBoundFunc:function(){return{x:this.absolutePosition().x,y:this.absolutePosition().y}},onMouseMove:st,onMouseOver:st,onMouseOut:()=>{Y&&Y.hide()},onDragStart:function(t){const{target:e}=t,i=e.getStage();if(i){const t=i.getPointerPosition();t&&(I.current=t.x)}},onDragMove:at,onDragEnd:t=>{const{target:e}=t,i=e.getStage();i&&(i.container().style.cursor="pointer")},onWheel:dt,children:[X.jsxs(p,{children:[X.jsx(m,{x:0,y:0,width:o,height:E,stroke:q.grid,strokeWidth:1}),$.map(((t,e)=>X.jsx(g,{points:t,stroke:q.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},e))),Q.map(((t,e)=>X.jsx(g,{points:t,stroke:q.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},e))),_.map(((t,e)=>X.jsx(g,{points:t,stroke:"#9d9d9d",strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},e))),K.map(((t,e)=>X.jsx(h,{x:t.x,y:t.y,text:t.text,fontFamily:"Manrope",fontSize:12,fill:"#9d9d9d",width:F,padding:0,align:"center",verticalAlign:"bottom",listening:!1},e))),X.jsx(g,{points:et,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:E},fillLinearGradientEndPoint:{x:0,y:it},fillLinearGradientColorStops:q.leftBg}),X.jsx(g,{points:U,stroke:q.leftLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),X.jsx(g,{points:rt,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:W,y:E},fillLinearGradientEndPoint:{x:W,y:nt},fillLinearGradientColorStops:q.rightBg}),X.jsx(g,{points:ot,stroke:q.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),X.jsx(g,{points:lt,stroke:q.midPriceLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]}),X.jsxs(p,{ref:J,visible:!1,listening:!1,children:[X.jsx(g,{points:[],stroke:"#ff4f73",strokeWidth:1,lineCap:"round",lineJoin:"round",dash:[4,6],id:"toolTipVertLine"}),X.jsx(g,{points:[],stroke:"ff4f73",strokeWidth:1,lineCap:"round",lineJoin:"round",dash:[4,6],id:"toolTipHoriLine"}),X.jsx(b,{x:0,y:0,radius:5,fill:"#FF5072",stroke:"rgba(255, 80, 114, 0.3)",strokeWidth:12,id:"joinCircle"}),X.jsxs(f,{x:0,y:0,id:"priceTextLabel",children:[X.jsx(M,{fill:q.tooltipBg,id:"priceTextLabel-tag"}),X.jsx(h,{text:"",fontSize:12,fontFamily:"Manrope",padding:4,fill:"#FF5072",id:"priceTextLabel-text"})]}),X.jsxs(f,{x:0,y:0,id:"slippageTextLabel",children:[X.jsx(M,{fill:q.tooltipBg,id:"slippageTextLabel-tag"}),X.jsx(h,{text:"",fontSize:12,fontFamily:"Manrope",padding:4,fill:"#FF5072",id:"slippageTextLabel-text"})]}),X.jsxs(f,{x:0,y:0,id:"toolTip",children:[X.jsx(M,{fill:q.tooltipBg,pointerDirection:"down",pointerWidth:15,pointerHeight:8,cornerRadius:8,lineJoin:"round",id:"toolTip-tag"}),X.jsx(h,{text:"-",fontSize:12,lineHeight:17/12,padding:B,fontFamily:"Manrope",fill:"#FFFFFF",id:"toolTip-text"})]})]})]})}const it=d.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
|
-
`,ot=d.div`
|
|
33
|
-
height: 100%;
|
|
34
|
-
`,rt=d.div`
|
|
35
|
-
display: flex;
|
|
36
|
-
align-items: center;
|
|
37
|
-
`,nt=d.div`
|
|
38
|
-
border: 1px solid ${({borderColor:t})=>t||"#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
|
-
`,lt=d.span`
|
|
53
|
-
color: #85858d;
|
|
54
|
-
`,st=d.div`
|
|
55
|
-
margin-top: 20px;
|
|
56
|
-
display: flex;
|
|
57
|
-
justify-content: center;
|
|
58
|
-
margin-bottom: 9px;
|
|
59
|
-
`,at=d(it)`
|
|
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 dt({params:e,target:i,isBuy:o=!0}){const r=new t(e.b),n=new t(e.q);let l=new t(e.b0);const s=new t(e.q0),a=new t(e.i),d=new t(e.k),{R:u}=e;1===u&&l.eq(r)&&(l=q(r,n.minus(s),new t(1).div(a),d));const c=o?r.plus(i):r.minus(i);if(c.lt(l)||r.eq(l)){let e=l.multipliedBy(l).div(c).div(c);return e=new t(1).minus(d).plus(d.multipliedBy(e)),a.multipliedBy(e)}const p=new W;p.RStatus=u,p.B=r,p.B0=l,p.Q=n,p.Q0=s,p.i=a,p.k=d,p.mtFeeRate=new t(0),p.lpFeeRate=new t(0);let m=new t(0);m=o?p.querySellBase(i):p.queryBuyBase(i);const g=o?n.minus(m):n.plus(m);let h=s.multipliedBy(s).div(g).div(g);return h=new t(1).minus(d).plus(d.multipliedBy(h)),a.div(h)}const ut=({chartId:e,width:i=834,height:r=460,baseTokenSymbol:s,quoteTokenSymbol:d,pmmModel:u,pmmParams:c,midPrice:p=new t(0),colorMap:m,notShowAmountInput:g})=>{(({id:t})=>{n((()=>{function e(t){t.preventDefault()}let i=!1;try{const t={get passive(){return i=!0,!1}};window.addEventListener("test",(()=>{}),t),window.removeEventListener("test",(()=>{}))}catch(t){i=!1}const o=document.getElementById(t),r=!!i&&{passive:!1};return null==o||o.addEventListener("wheel",e,r),()=>{null==o||o.removeEventListener("wheel",e)}}),[t])})({id:e});const[h,b]=a(""),[f,M]=a(""),[v,x]=a("-"),[y,z]=a("-"),[k,B]=a({baseMin:new t(0),zoomMultiples:C,targetMarginPriceX:0});n((()=>{void 0!==p&&B((t=>({baseMin:j({midPrice:p,zoomMultiples:t.zoomMultiples}),zoomMultiples:t.zoomMultiples,targetMarginPriceX:t.targetMarginPriceX})))}),[p]);const O=l((()=>o((({type:e,amount:o})=>{""===o&&p&&(B({baseMin:j({midPrice:p,zoomMultiples:C}),zoomMultiples:C,targetMarginPriceX:0}),"buy"===e?x("-"):z("-"));const r=new t(o);if(!r.lte(0)&&!r.isNaN()&&(null==c?void 0:c.b)&&!r.gte(c.b)&&p)if("buy"===e){const t=dt({params:c,target:r});B((o=>{const r=S({currentBaseMinAndZoomMultiples:o,targetPrice:t,midPrice:p,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:p,width:i,type:e,targetPrice:t}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:j({midPrice:p,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}})),x(`${T({input:t.minus(p).div(p)})}`)}else{const t=function({params:t,target:e}){return dt({params:t,target:e,isBuy:!1})}({params:c,target:r});B((o=>{const r=S({currentBaseMinAndZoomMultiples:o,targetPrice:t,midPrice:p,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:p,width:i,type:e,targetPrice:t}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:j({midPrice:p,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}})),z(`+${T({input:t.minus(p).div(p)})}`)}}),300)),[c,p,i]);n((()=>{void 0!==h&&O({type:"buy",amount:h})}),[O,h]),n((()=>{void 0!==f&&O({type:"sell",amount:f})}),[O,f]);const q=t=>{let e=0;e=t?-.1*i:.1*i,B((t=>void 0===t.baseMin?t:{baseMin:P({dragDistance:e,prevBaseMin:t.baseMin,chartWidth:i,zoomMultiples:t.zoomMultiples}),zoomMultiples:t.zoomMultiples,targetMarginPriceX:t.targetMarginPriceX}))},W=t=>{B((e=>{const i=w({zoomIn:null!=t&&t,prevZoomMultiples:e.zoomMultiples});return{baseMin:j({midPrice:p,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:e.targetMarginPriceX}}))},E=l((()=>{if(""===h)return!1;const e=new t(h);return!(!e.lte(0)&&!e.isNaN()&&(null==c?void 0:c.b)&&!e.gte(c.b))}),[h,c]),F=l((()=>{if(""===f)return!1;const e=new t(f);return!(!e.lte(0)&&!e.isNaN()&&(null==c?void 0:c.b)&&!e.gte(c.b))}),[f,c]);return X.jsxs(ot,{id:e,children:[g?"":X.jsxs(rt,{children:[X.jsxs(nt,{borderColor:m&&m.grid,children:[L("pool.chart.buy-amount",{symbol:s}),X.jsx(U,{value:h,error:E,onChange:t=>{const e=A(t.target.value,2);null!==e&&b(e)}}),X.jsx(lt,{children:L("pool.chart.price-impact",{amount:v})})]}),X.jsxs(nt,{borderColor:m&&m.grid,children:[L("pool.chart.sell-amount",{symbol:s}),X.jsx(U,{value:f,error:F,onChange:t=>{const e=A(t.target.value,2);null!==e&&M(e)}}),X.jsx(lt,{children:L("pool.chart.price-impact",{amount:y})})]})]}),void 0!==c&&void 0!==p&&void 0!==u&&void 0!==k.baseMin&&void 0!==p&&X.jsx(et,{width:i,height:r,params:c,midPrice:p,pmmModel:u,baseTokenSymbol:s,quoteTokenSymbol:d,baseMinAndZoomMultiples:k,colorMap:m,setBaseMinAndZoomMultiples:B}),X.jsxs(st,{className:"operate-btn-wrapper",children:[X.jsx(at,{onClick:()=>q(!0),children:X.jsx($,{})}),X.jsx(at,{onClick:()=>W(!1),children:X.jsx(_,{})}),X.jsx(at,{onClick:()=>W(!0),children:X.jsx(K,{})}),X.jsx(at,{onClick:()=>q(!1),children:X.jsx(Q,{})})]})]})};export{ut as default};
|
package/dist/index-D8Yofu94.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import t from"@emotion/styled";import{merge as i}from"lodash";import{useMemo as e,useRef as n}from"react";import{l as r,g as o,m as l}from"./helper-B-L9J5Wk.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{j as h,f}from"./index-BYYZxbt3.js";import x from"bignumber.js";import{solveQuadraticFunctionForTarget as L,PMMState as w,PMMHelper as b}from"@dodoex/api";import"@lingui/core";import"@lingui/react";import"@dodoex/components";import"@web3-react/core";import"axios";import"@ethersproject/bignumber";import"zustand";import"@dodoex/dodo-contract-request";import"@tanstack/react-query";import"@reown/appkit-utils";import"@reown/appkit-common";import"os";import"events";import"fs";import"util";import"path";import"worker_threads";import"module";import"url";import"buffer";import"assert";import"stream";import"http";import"punycode";import"https";import"zlib";import"@web3-react/eip1193";import"@web3-react/walletconnect-v2";import"@web3-react/metamask";import"@web3-react/types";import"@ethersproject/contracts";import"identicon.js";import"react-dom";import"dayjs";import"react-transition-group";import"@dodoex/contract-request";import"recharts";import"react-window";import"jsbi";import"tiny-invariant";import"@ethersproject/units";import"@uniswap/sdk-core";import"@uniswap/v2-sdk";import"react-infinite-scroller";import"d3";import"rmc-date-picker";const A=t.div`
|
|
2
|
-
height: 100%;
|
|
3
|
-
position: relative;
|
|
4
|
-
`,y=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
|
-
`,N=36;function P({maxHeight:t,gridAreaHeight:i,value:e}){const n=new x(i).minus(N),r=n.div(t);return n.minus(e.multipliedBy(r)).plus(N).toNumber()}function v({targetPrice:t,areaPoints:i,isLeft:e}){for(let n=0;n<i.length;n++){const r=i[n],o=n<i.length-1?i[n+1]:null;if(!o)return{targetAreaStatPoint:r,targetAreaStatPoints:i};if(e){if(t.lte(r.middlePrice)&&t.gte(o.middlePrice))return{targetAreaStatPoint:r,targetAreaStatPoints:i.slice(0,n+1)}}else if(t.gte(r.middlePrice)&&t.lte(o.middlePrice))return{targetAreaStatPoint:r,targetAreaStatPoints:i.slice(0,n+1)}}return{targetAreaStatPoint:null,targetAreaStatPoints:[]}}function j({x:t,width:i,minXLN10:e,maxXLN10:n}){const r=new x(t).div(i).multipliedBy(n.minus(e)).plus(e);return new x(10**r.toNumber())}function H({width:t,targetLN10:i,minXLN10:e,maxXLN10:n}){return i.minus(e).div(n.minus(e)).multipliedBy(t).toNumber()}function S({target:t}){return new x(Math.log10(t.toNumber()))}const k="rgba(38, 39, 41, 0.3)";function X({width:t,height:A,params:y,baseTokenSymbol:N,quoteTokenSymbol:X,colorMap:B}){const{maxLeftHeight:C,maxRightHeight:F,leftStatAreaPoints:M,rightStatAreaPoints:W,minXLN10:T,maxXLN10:q}=function({params:t}){return e((()=>{const i=new x(t.b),e=new x(t.q);let n=new x(t.b0);const r=new x(t.q0),o=new x(t.i),l=new x(t.k),{R:a}=t;1===a&&n.eq(i)&&(n=L(i,e.minus(r),new x(1).div(o),l));const s=new w({i:o,K:l,B:i,Q:e,B0:n,Q0:r,R:a,mtFeeRate:new x(0),lpFeeRate:new x(0)}),d=new b,m=new x(s.B),p=[],g=[];let u=new x(0),c=new x(0);const h=d.GetMidPrice(s),f=e.gt(0)?i.div(e):new x(1);for(let t=0;t<=250;t++){let i=m.multipliedBy(t/100).multipliedBy(h.multipliedBy(f).multipliedBy(4));0===t&&(i=m.multipliedBy(1e-11));const e=null==d?void 0:d.QuerySellBase(i,s);if(e.isNaN()||!e.gt(0))p.push({giveAmount:i,getAmount:new x(0),price:new x(0)});else{const t=e.div(i);p.push({giveAmount:i,getAmount:e,price:t})}}for(let t=0;t<=250;t++){let i=m.multipliedBy(t/100).multipliedBy(h.multipliedBy(4));0===t&&(i=m.multipliedBy(1e-11));const e=null==d?void 0:d.QuerySellQuote(i,s);if(e.isNaN()||!e.gt(0))g.push({giveAmount:i,getAmount:new x(0),price:new x(0)});else{const t=i.dividedBy(e);g.push({giveAmount:i,getAmount:e,price:t})}}if(p.length<2&&g.length<2)return{leftStatAreaPoints:[],rightStatAreaPoints:[],maxLeftHeight:new x(10).multipliedBy(1.2),maxRightHeight:new x(10).multipliedBy(1.2),middlePriceLN10:new x(0),minXLN10:new x(-1),maxXLN10:new x(1)};const A=[];for(let t=1;t<p.length;t++){const i=p[t],{giveAmount:e,getAmount:n,price:r}=i,o=p[t-1];if(!r.isNaN()&&r.gt(0)&&o){const i=r.minus(o.price).abs(),l=e.minus(o.giveAmount).abs(),a=n.minus(o.getAmount).abs().multipliedBy(l);1===t&&A.push({area:n,price:r,middlePrice:r.plus(i.div(1.1)),rectangleHeight:a.plus(a.multipliedBy(.03))}),A.push({area:n,price:r,middlePrice:r.plus(i.div(2)),rectangleHeight:a}),u=x.max(a,u)}}const y=[];for(let t=1;t<g.length;t++){const i=g[t],{giveAmount:e,getAmount:n,price:r}=i,o=g[t-1],l=o.price,a=o.giveAmount,s=o.getAmount;if(!r.isNaN()&&r.gt(0)&&o){const i=r.minus(l).abs(),o=e.minus(a).abs(),d=n.minus(s).abs().multipliedBy(o);1===t&&y.push({area:n,price:r,middlePrice:r.minus(i.div(1.1)),rectangleHeight:d.plus(d.multipliedBy(.03))}),y.push({area:n,price:r,middlePrice:r.minus(i.div(2)),rectangleHeight:d}),c=x.max(d,c)}}const N=p.length>0?p[p.length-1]:g[0],P=g.length>0?g[0]:p[0],v=g.length>0?g[g.length-1]:p[0],j=N.price,H=v.price,S=P.price,k=new x(Math.log10(S.toNumber()));let X=j.gt(0)?new x(Math.log10(j.toNumber())):new x(-Math.log10(H.toNumber())),B=H.gt(0)?new x(Math.log10(H.toNumber())):new x(-Math.log10(j.toNumber()));const C=x.max(k.minus(X).abs(),B.minus(k).abs());return X=k.minus(C),B=k.plus(C),{leftStatAreaPoints:A,rightStatAreaPoints:y,maxLeftHeight:u.multipliedBy(1.2),maxRightHeight:c.multipliedBy(1.2),minXLN10:X,maxXLN10:B,middlePriceLN10:k}}),[t])}({params:y}),J=A-30.13,O=n(null),R=i({grid:"#2A2A2D",midPriceLine:"#313335",leftBg:[0,k,1,"#31645d"],leftLine:"#55f6db",leftColor:"",rightBg:[0,k,1,"#67303d"],rightLine:"#ff4f73",rightColor:"",tooltipBg:"#121212",tooltipColor:void 0,textColor:"#606066"},B),z=i=>{var e;const{current:n}=O,r=i.target;if(r&&n){const i=null===(e=r.getStage())||void 0===e?void 0:e.getPointerPosition();if(i){const{x:e}=i,r=t/2;if(Math.abs(e-r)<=2)return;if(e<=2||t-e<=2)return;const a=j({x:e,width:t,minXLN10:T,maxXLN10:q});let s=null,d=[];const m=e<r;if(m){const t=v({areaPoints:M,targetPrice:a,isLeft:m});s=t.targetAreaStatPoint,d=t.targetAreaStatPoints}else{const t=v({areaPoints:W,targetPrice:a,isLeft:m});s=t.targetAreaStatPoint,d=t.targetAreaStatPoints}if(s){const i=S({target:s.middlePrice}),r=H({minXLN10:T,maxXLN10:q,width:t,targetLN10:i}),a=P({maxHeight:m?C:F,gridAreaHeight:J,value:s.rectangleHeight}),p=n.findOne("#tooltip"),g=n.findOne("#toolTipVertLine"),u=n.findOne("#joinCircle"),c=n.findOne("#tooltip-Text"),h=n.findOne("#tooltip-tag"),x=n.findOne("#priceTextLabel"),L=null==x?void 0:x.findOne("#priceTextLabel-text"),w=n.findOne("#area");null==p||p.position({x:r,y:a-5-6}),null==c||c.fill(R.tooltipColor||(m?"#00FAD9":"#FF5072")),null==c||c.text(m?o("pool.chart.liquidity-chart-buy",{amount:f(s.area),symbol:N,price:f(s.price)}):o("pool.chart.liquidity-chart-sell",{amount:f(s.area),symbol:X,price:f(s.price)})),p&&h&&(p.width()/2>e?(h.pointerDirection("left"),h.pointerHeight(15),h.pointerWidth(8),p.offsetX(-11),p.offsetY(-11)):p.width()/2+e>t?(h.pointerDirection("right"),h.pointerHeight(15),h.pointerWidth(8),p.offsetX(11),p.offsetY(-11)):(h.pointerDirection("down"),h.pointerHeight(8),h.pointerWidth(15),p.offsetX(0),p.offsetY(0))),null==g||g.points([r,J,r,a]),null==g||g.stroke(m?"#55f6db":"#ff4f73");let b=m?"rgb(86, 246, 218)":"#FF5072",A=m?"rgba(86, 246, 218, 0.3)":"rgba(255, 80, 114, 0.3)";R.leftLine&&R.rightLine&&(b=m?R.leftLine:R.rightLine,A=m?`rgba(${l(R.leftLine)}, 0.4)`:`rgba(${l(R.rightLine)}, 0.4)`),u&&(u.x(r),u.y(a),u.fill(b),u.stroke(A)),x&&(x.x(r),x.y(J+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(e)),L&&(L.fill(R.tooltipColor||(m?"#00FAD9":"#FF5072")),L.text(f(s.price)));const y=[];for(const i of d){const{middlePrice:e,rectangleHeight:n}=i,r=S({target:e}),o=H({minXLN10:T,maxXLN10:q,width:t,targetLN10:r}),l=P({maxHeight:m?C:F,gridAreaHeight:J,value:n});y.push(o,l+1)}const v=y.slice(),[j,k]=v;m?(v.push(r,a),v.push(r,J),v.push(j,J),v.push(j,k)):(v.unshift(j,J),v.unshift(r,J),v.unshift(r,a)),w&&(w.points(v),w.fill(m?R.leftLine||"#2c5b56":R.rightLine||"#7b3a48")),n.show()}}}},D=function({gridAreaHeight:t,gridAreaWidth:i,horizontalLineCount:n,verticalLineCount:r,color:o="#2A2A2D"}){return e((()=>{const e=[],l=t/(n+1),s=[],d=i/(r+1);for(let t=0;t<n;t++){const n=l*(t+1);e.push([0,n,i,n])}for(let i=0;i<r;i++){const e=d*(i+1);s.push([e,0,e,t])}return h.jsxs(h.Fragment,{children:[e.map(((t,i)=>h.jsx(a,{points:t,stroke:o,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1},i))),s.map(((t,i)=>h.jsx(a,{points:t,stroke:o,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1},i)))]})}),[t,i,n,r,o])}({gridAreaHeight:J,gridAreaWidth:t,horizontalLineCount:9,verticalLineCount:7,color:R.grid}),G=function({minXLN10:t,maxXLN10:i,labelCount:n,gridAreaHeight:r,gridAreaWidth:o,color:l="#606066"}){return e((()=>{const e=o/(n+1),d=[],m=[];for(let l=0;l<n;l++){const n=e/2+e*l;d.push({x:n,y:r+10.08+1,text:f(j({x:e*(l+1),width:o,minXLN10:t,maxXLN10:i}))});const a=e*(l+1);m.push([a,r+1,a,r+4+1])}return h.jsxs(h.Fragment,{children:[d.map(((t,i)=>h.jsx(s,{x:t.x,y:t.y,text:t.text,fontSize:14,fontFamily:"Manrope",fill:l,width:e,padding:0,align:"center",verticalAlign:"bottom",listening:!1},i))),m.map(((t,i)=>h.jsx(a,{points:t,stroke:l,strokeWidth:1,lineCap:"butt",lineJoin:"miter",tension:1,listening:!1},i)))]})}),[t,i,r,o,n])}({gridAreaHeight:J,gridAreaWidth:t,labelCount:7,minXLN10:T,maxXLN10:q,color:R.textColor}),Q=function({gridAreaHeight:t,gridAreaWidth:i,color:n="#606066"}){return e((()=>{const e=i/2;return h.jsx(a,{points:[e,0,e,t-1],stroke:n,strokeWidth:1,lineCap:"round",lineJoin:"round",tension:1,listening:!1})}),[t,i,n])}({gridAreaHeight:J,gridAreaWidth:t,color:R.midPriceLine}),{leftLine:E,rightLine:Y}=function({leftStatAreaPoints:t,rightStatAreaPoints:i,minXLN10:n,maxXLN10:r,maxLeftHeight:o,maxRightHeight:l,gridAreaWidth:s,gridAreaHeight:d,colorMap:m}){return{leftLine:e((()=>{if(t.length<1)return h.jsx(h.Fragment,{});const i=[];let e=d;for(const l of t){const{middlePrice:t,rectangleHeight:a}=l,m=S({target:t}),p=H({minXLN10:n,maxXLN10:r,width:s,targetLN10:m}),g=P({maxHeight:o,gridAreaHeight:d,value:a});i.push(p,g),g<e&&(e=g)}const l=i.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),h.jsxs(h.Fragment,{children:[h.jsx(a,{points:l,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:d},fillLinearGradientEndPoint:{x:0,y:e},fillLinearGradientColorStops:m.leftBg}),h.jsx(a,{points:i,stroke:m.leftLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})}),[t,s,n,r,d,o]),rightLine:e((()=>{if(i.length<1)return h.jsx(h.Fragment,{});const t=[];let e=d;for(const o of i){const{middlePrice:i,rectangleHeight:a}=o,m=S({target:i}),p=H({minXLN10:n,maxXLN10:r,width:s,targetLN10:m}),g=P({maxHeight:l,gridAreaHeight:d,value:a});t.push(p,g),g<e&&(e=g)}const o=t.slice(),[p]=o;return o.unshift(p,d),o.unshift(s,d),h.jsxs(h.Fragment,{children:[h.jsx(a,{points:o,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:d},fillLinearGradientEndPoint:{x:0,y:e},fillLinearGradientColorStops:m.rightBg}),h.jsx(a,{points:t,stroke:m.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})}),[i,s,n,r,d,l])}}({leftStatAreaPoints:M,rightStatAreaPoints:W,minXLN10:T,maxXLN10:q,maxLeftHeight:C,maxRightHeight:F,gridAreaWidth:t,gridAreaHeight:J,colorMap:R});return h.jsxs(d,{width:t,height:A,onMouseMove:z,onMouseOver:z,onMouseEnter:z,onMouseOut:()=>{const{current:t}=O;t&&t.hide()},children:[h.jsxs(m,{children:[h.jsx(p,{x:0,y:0,width:t,height:J,stroke:R.grid,strokeWidth:1}),D,G,E,Y,Q]}),h.jsxs(m,{ref:O,visible:!1,children:[h.jsx(a,{points:[],closed:!0,listening:!1,lineCap:"round",lineJoin:"round",id:"area"}),h.jsx(a,{points:[],strokeWidth:1,stroke:"#ff4f73",lineJoin:"round",lineCap:"round",dash:[4,6],id:"toolTipVertLine"}),h.jsx(g,{x:0,y:0,radius:5,fill:"#FF5072",stroke:"rgba(255, 80, 114, 0.3)",strokeWidth:12,id:"joinCircle"}),h.jsxs(u,{listening:!1,x:0,y:0,id:"priceTextLabel",children:[h.jsx(c,{fill:R.tooltipBg,id:"priceTextLabel-tag"}),h.jsx(s,{text:"-",fontSize:14,fontFamily:"Manrope",padding:2,fill:"#FF5072",id:"priceTextLabel-text"})]}),h.jsxs(u,{listening:!1,id:"tooltip",children:[h.jsx(c,{fill:R.tooltipBg,pointerDirection:"down",pointerWidth:15,pointerHeight:8,cornerRadius:8,lineJoin:"round",id:"tooltip-tag"}),h.jsx(s,{text:"",fontFamily:"Manrope",fontSize:12,lineHeight:17/12,padding:r,fill:"#FF5072",id:"tooltip-Text"})]})]})]})}const B=({width:t=834,height:i=462,baseTokenSymbol:e,quoteTokenSymbol:n,pmmModel:r,pmmParams:l,midPrice:a,notShowTipText:s,colorMap:d})=>h.jsxs(A,{children:[void 0!==l&&void 0!==a&&void 0!==r&&void 0!==a&&h.jsx(X,{width:t,height:i,params:l,midPrice:a,pmmModel:r,baseTokenSymbol:e,quoteTokenSymbol:n,colorMap:d}),s?"":h.jsxs(y,{children:["* ",o("pool.chart.liquidity-chart-tip",{baseTokenSymbol:e})]})]});export{B as default};
|