@dodoex/widgets 3.0.2-zetachain.108.ton.2 → 3.0.2-zetachain.108.ton.4
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-BhnlkePU.js → helper-CLElCboD.js} +1 -1
- package/dist/{helper-xbWu0aGJ.cjs → helper-ClDVNp1x.cjs} +1 -1
- package/dist/index-BZUoTGh3.js +34 -0
- package/dist/{index-CsrFbHKk.js → index-CNqXq0K8.js} +1 -1
- package/dist/{index-gSLR54il.cjs → index-CSUUT5Yj.cjs} +2 -2
- package/dist/index-Cl9wvOiK.cjs +34 -0
- package/dist/{index--IQw92GO.cjs → index-d550SLmT.cjs} +1 -1
- package/dist/{index-BXOd9Dl2.js → index-r-jtP40I.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types/utils/sui_test.d.ts +1 -0
- package/dist/types/utils/ton.d.ts +2 -8
- package/package.json +1 -1
- package/dist/index-BNjT4_s4.js +0 -31
- package/dist/index-DMfCNiUx.cjs +0 -31
|
@@ -1,4 +1,4 @@
|
|
|
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 c}from"@emotion/react";import{Stage as u,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 x,e as v,a as y,b as P,d as j,f as w,u as z,g as L,h as k,l as B,i as C,j as S,k as N}from"./helper-
|
|
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 c}from"@emotion/react";import{Stage as u,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 x,e as v,a as y,b as P,d as j,f as w,u as z,g as L,h as k,l as B,i as C,j as S,k as N}from"./helper-CLElCboD.js";import{f as O,j as X,a as T,b as A}from"./index-BZUoTGh3.js";import{solveQuadraticFunctionForTarget as q,PMMModel as W}from"@dodoex/api";import"@lingui/core";import"@lingui/react";import"@dodoex/components";import"@solana/web3.js";import"@reown/appkit/networks";import"@tanstack/react-query";import"zustand";import"@dodoex/dodo-contract-request";import"@ethersproject/providers";import"@mysten/dapp-kit";import"@reown/appkit/react";import"@tonconnect/ui-react";import"@ethersproject/bignumber";import"axios";import"@ethersproject/contracts";import"react-dom";import"identicon.js";import"@ton/core";import"@bitcoinerlab/secp256k1";import"bitcoinjs-lib";import"@ton/ton";import"dayjs";import"@dodoex/contract-request";import"react-transition-group";import"recharts";import"react-window";import"jsbi";import"tiny-invariant";import"@ethersproject/units";import"react-infinite-scroller";import"@uniswap/sdk-core";import"@uniswap/v2-sdk";import"d3";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 K(t){return I({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M5 11h14v2H5z"},child:[]}]})(t)}function U(t){return I({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z"},child:[]}]})(t)}const _=d.input`
|
|
2
2
|
margin: 4px 10px 4px 6px;
|
|
3
3
|
border-radius: 10px;
|
|
4
4
|
border: 1px solid #373739;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var e=require("@emotion/styled"),t=require("lodash"),i=require("react"),r=require("./helper-
|
|
1
|
+
"use strict";var e=require("@emotion/styled"),t=require("lodash"),i=require("react"),r=require("./helper-ClDVNp1x.cjs"),n=require("react-konva"),o=require("./index-Cl9wvOiK.cjs"),s=require("bignumber.js"),l=require("@dodoex/api");require("@lingui/core"),require("@lingui/react"),require("@dodoex/components"),require("@solana/web3.js"),require("@reown/appkit/networks"),require("@tanstack/react-query"),require("zustand"),require("@dodoex/dodo-contract-request"),require("@ethersproject/providers"),require("@mysten/dapp-kit"),require("@reown/appkit/react"),require("@tonconnect/ui-react"),require("@ethersproject/bignumber"),require("axios"),require("@ethersproject/contracts"),require("react-dom"),require("identicon.js"),require("@ton/core"),require("@bitcoinerlab/secp256k1"),require("bitcoinjs-lib"),require("@ton/ton"),require("dayjs"),require("@dodoex/contract-request"),require("react-transition-group"),require("recharts"),require("react-window"),require("jsbi"),require("tiny-invariant"),require("@ethersproject/units"),require("react-infinite-scroller"),require("@uniswap/sdk-core"),require("@uniswap/v2-sdk"),require("d3");const a=e.div`
|
|
2
2
|
height: 100%;
|
|
3
3
|
position: relative;
|
|
4
4
|
`,u=e.div`
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
font-size: 12px;
|
|
10
10
|
line-height: 17px;
|
|
11
11
|
font-weight: 400;
|
|
12
|
-
`,d=36;function g({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 m({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:j,maxRightHeight:b,leftStatAreaPoints:w,rightStatAreaPoints:A,minXLN10:y,maxXLN10:N}=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),p=[],c=[];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))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=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))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 j=[];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&&j.push({area:r,price:n,middlePrice:n.plus(t.div(1.1)),rectangleHeight:a.plus(a.multipliedBy(.03))}),j.push({area:r,price:n,middlePrice:n.plus(t.div(2)),rectangleHeight:a}),h=s.max(a,h)}}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],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&&b.push({area:r,price:n,middlePrice:n.minus(t.div(1.1)),rectangleHeight:d.plus(d.multipliedBy(.03))}),b.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],A=c.length>0?c[0]:p[0],y=c.length>0?c[c.length-1]:p[0],N=w.price,P=y.price,q=A.price,R=new s(Math.log10(q.toNumber()));let v=N.gt(0)?new s(Math.log10(N.toNumber())):new s(-Math.log10(P.toNumber())),S=P.gt(0)?new s(Math.log10(P.toNumber())):new s(-Math.log10(N.toNumber()));const H=s.max(R.minus(v).abs(),S.minus(R).abs());return v=R.minus(H),S=R.plus(H),{leftStatAreaPoints:j,rightStatAreaPoints:b,maxLeftHeight:h.multipliedBy(1.2),maxRightHeight:x.multipliedBy(1.2),minXLN10:v,maxXLN10:S,middlePriceLN10:R}}),[e])}({params:u}),P=a-30.13,q=i.useRef(null),R=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),v=t=>{var i;const{current:n}=q,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:y,maxXLN10:N});let a=null,u=[];const x=i<s;if(x){const e=m({areaPoints:w,targetPrice:l,isLeft:x});a=e.targetAreaStatPoint,u=e.targetAreaStatPoints}else{const e=m({areaPoints:A,targetPrice:l,isLeft:x});a=e.targetAreaStatPoint,u=e.targetAreaStatPoints}if(a){const t=h({target:a.middlePrice}),s=c({minXLN10:y,maxXLN10:N,width:e,targetLN10:t}),l=g({maxHeight:x?j:b,gridAreaHeight:P,value:a.rectangleHeight}),m=n.findOne("#tooltip"),p=n.findOne("#toolTipVertLine"),L=n.findOne("#joinCircle"),w=n.findOne("#tooltip-Text"),A=n.findOne("#tooltip-tag"),q=n.findOne("#priceTextLabel"),v=null==q?void 0:q.findOne("#priceTextLabel-text"),S=n.findOne("#area");null==m||m.position({x:s,y:l-5-6}),null==w||w.fill(R.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)})),m&&A&&(m.width()/2>i?(A.pointerDirection("left"),A.pointerHeight(15),A.pointerWidth(8),m.offsetX(-11),m.offsetY(-11)):m.width()/2+i>e?(A.pointerDirection("right"),A.pointerHeight(15),A.pointerWidth(8),m.offsetX(11),m.offsetY(-11)):(A.pointerDirection("down"),A.pointerHeight(8),A.pointerWidth(15),m.offsetX(0),m.offsetY(0))),null==p||p.points([s,P,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)";R.leftLine&&R.rightLine&&(H=x?R.leftLine:R.rightLine,E=x?`rgba(${r.colorRgb(R.leftLine)}, 0.4)`:`rgba(${r.colorRgb(R.rightLine)}, 0.4)`),L&&(L.x(s),L.y(l),L.fill(H),L.stroke(E)),q&&(q.x(s),q.y(P+8.08+1),q.offsetX(q.width()/2),q.x()-q.width()/2<0?q.x(q.width()/2):q.x()+q.width()/2>e?q.x(e-q.width()/2):q.x(i)),v&&(v.fill(R.tooltipColor||(x?"#00FAD9":"#FF5072")),v.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:y,maxXLN10:N,width:e,targetLN10:n}),s=g({maxHeight:x?j:b,gridAreaHeight:P,value:r});k.push(o,s+1)}const X=k.slice(),[M,B]=X;x?(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)),S&&(S.points(X),S.fill(x?R.leftLine||"#2c5b56":R.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:P,gridAreaWidth:e,horizontalLineCount:9,verticalLineCount:7,color:R.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:P,gridAreaWidth:e,labelCount:7,minXLN10:y,maxXLN10:N,color:R.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:R.midPriceLine}),{leftLine:k,rightLine:X}=function({leftStatAreaPoints:e,rightStatAreaPoints:t,minXLN10:r,maxXLN10:s,maxLeftHeight:l,maxRightHeight:a,gridAreaWidth:u,gridAreaHeight:d,colorMap:m}){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}),m=c({minXLN10:r,maxXLN10:s,width:u,targetLN10:a}),p=g({maxHeight:l,gridAreaHeight:d,value:o});t.push(m,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:m.leftBg}),o.jsxRuntimeExports.jsx(n.Line,{points:t,stroke:m.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}),m=c({minXLN10:r,maxXLN10:s,width:u,targetLN10:l}),p=g({maxHeight:a,gridAreaHeight:d,value:o});e.push(m,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:m.rightBg}),o.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:m.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})}),[t,u,r,s,d,a])}}({leftStatAreaPoints:w,rightStatAreaPoints:A,minXLN10:y,maxXLN10:N,maxLeftHeight:j,maxRightHeight:b,gridAreaWidth:e,gridAreaHeight:P,colorMap:R});return o.jsxRuntimeExports.jsxs(n.Stage,{width:e,height:a,onMouseMove:v,onMouseOver:v,onMouseEnter:v,onMouseOut:()=>{const{current:e}=q;e&&e.hide()},children:[o.jsxRuntimeExports.jsxs(n.Layer,{children:[o.jsxRuntimeExports.jsx(n.Rect,{x:0,y:0,width:e,height:P,stroke:R.grid,strokeWidth:1}),S,H,k,X,E]}),o.jsxRuntimeExports.jsxs(n.Layer,{ref:q,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:R.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:R.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(f,{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})]})]});
|
|
12
|
+
`,d=36;function g({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 m({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:j,maxRightHeight:b,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),p=[],c=[];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))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=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))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 j=[];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&&j.push({area:r,price:n,middlePrice:n.plus(t.div(1.1)),rectangleHeight:a.plus(a.multipliedBy(.03))}),j.push({area:r,price:n,middlePrice:n.plus(t.div(2)),rectangleHeight:a}),h=s.max(a,h)}}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],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&&b.push({area:r,price:n,middlePrice:n.minus(t.div(1.1)),rectangleHeight:d.plus(d.multipliedBy(.03))}),b.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],A=c.length>0?c[0]:p[0],N=c.length>0?c[c.length-1]:p[0],y=w.price,P=N.price,q=A.price,R=new s(Math.log10(q.toNumber()));let v=y.gt(0)?new s(Math.log10(y.toNumber())):new s(-Math.log10(P.toNumber())),S=P.gt(0)?new s(Math.log10(P.toNumber())):new s(-Math.log10(y.toNumber()));const H=s.max(R.minus(v).abs(),S.minus(R).abs());return v=R.minus(H),S=R.plus(H),{leftStatAreaPoints:j,rightStatAreaPoints:b,maxLeftHeight:h.multipliedBy(1.2),maxRightHeight:x.multipliedBy(1.2),minXLN10:v,maxXLN10:S,middlePriceLN10:R}}),[e])}({params:u}),P=a-30.13,q=i.useRef(null),R=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),v=t=>{var i;const{current:n}=q,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:N,maxXLN10:y});let a=null,u=[];const x=i<s;if(x){const e=m({areaPoints:w,targetPrice:l,isLeft:x});a=e.targetAreaStatPoint,u=e.targetAreaStatPoints}else{const e=m({areaPoints:A,targetPrice:l,isLeft:x});a=e.targetAreaStatPoint,u=e.targetAreaStatPoints}if(a){const t=h({target:a.middlePrice}),s=c({minXLN10:N,maxXLN10:y,width:e,targetLN10:t}),l=g({maxHeight:x?j:b,gridAreaHeight:P,value:a.rectangleHeight}),m=n.findOne("#tooltip"),p=n.findOne("#toolTipVertLine"),L=n.findOne("#joinCircle"),w=n.findOne("#tooltip-Text"),A=n.findOne("#tooltip-tag"),q=n.findOne("#priceTextLabel"),v=null==q?void 0:q.findOne("#priceTextLabel-text"),S=n.findOne("#area");null==m||m.position({x:s,y:l-5-6}),null==w||w.fill(R.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)})),m&&A&&(m.width()/2>i?(A.pointerDirection("left"),A.pointerHeight(15),A.pointerWidth(8),m.offsetX(-11),m.offsetY(-11)):m.width()/2+i>e?(A.pointerDirection("right"),A.pointerHeight(15),A.pointerWidth(8),m.offsetX(11),m.offsetY(-11)):(A.pointerDirection("down"),A.pointerHeight(8),A.pointerWidth(15),m.offsetX(0),m.offsetY(0))),null==p||p.points([s,P,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)";R.leftLine&&R.rightLine&&(H=x?R.leftLine:R.rightLine,E=x?`rgba(${r.colorRgb(R.leftLine)}, 0.4)`:`rgba(${r.colorRgb(R.rightLine)}, 0.4)`),L&&(L.x(s),L.y(l),L.fill(H),L.stroke(E)),q&&(q.x(s),q.y(P+8.08+1),q.offsetX(q.width()/2),q.x()-q.width()/2<0?q.x(q.width()/2):q.x()+q.width()/2>e?q.x(e-q.width()/2):q.x(i)),v&&(v.fill(R.tooltipColor||(x?"#00FAD9":"#FF5072")),v.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:N,maxXLN10:y,width:e,targetLN10:n}),s=g({maxHeight:x?j:b,gridAreaHeight:P,value:r});k.push(o,s+1)}const X=k.slice(),[M,B]=X;x?(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)),S&&(S.points(X),S.fill(x?R.leftLine||"#2c5b56":R.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:P,gridAreaWidth:e,horizontalLineCount:9,verticalLineCount:7,color:R.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:P,gridAreaWidth:e,labelCount:7,minXLN10:N,maxXLN10:y,color:R.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:R.midPriceLine}),{leftLine:k,rightLine:X}=function({leftStatAreaPoints:e,rightStatAreaPoints:t,minXLN10:r,maxXLN10:s,maxLeftHeight:l,maxRightHeight:a,gridAreaWidth:u,gridAreaHeight:d,colorMap:m}){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}),m=c({minXLN10:r,maxXLN10:s,width:u,targetLN10:a}),p=g({maxHeight:l,gridAreaHeight:d,value:o});t.push(m,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:m.leftBg}),o.jsxRuntimeExports.jsx(n.Line,{points:t,stroke:m.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}),m=c({minXLN10:r,maxXLN10:s,width:u,targetLN10:l}),p=g({maxHeight:a,gridAreaHeight:d,value:o});e.push(m,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:m.rightBg}),o.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:m.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]})}),[t,u,r,s,d,a])}}({leftStatAreaPoints:w,rightStatAreaPoints:A,minXLN10:N,maxXLN10:y,maxLeftHeight:j,maxRightHeight:b,gridAreaWidth:e,gridAreaHeight:P,colorMap:R});return o.jsxRuntimeExports.jsxs(n.Stage,{width:e,height:a,onMouseMove:v,onMouseOver:v,onMouseEnter:v,onMouseOut:()=>{const{current:e}=q;e&&e.hide()},children:[o.jsxRuntimeExports.jsxs(n.Layer,{children:[o.jsxRuntimeExports.jsx(n.Rect,{x:0,y:0,width:e,height:P,stroke:R.grid,strokeWidth:1}),S,H,k,X,E]}),o.jsxRuntimeExports.jsxs(n.Layer,{ref:q,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:R.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:R.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(f,{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})]})]});
|