@dodoex/widgets 3.0.0-beta.26 → 3.0.0-beta.28

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.
@@ -0,0 +1 @@
1
+ "use strict";var e=require("@lingui/core"),t=require("bignumber.js"),i=require("./index-DsbPHvau.cjs");function o(e){let t=e.toLowerCase();if(t&&/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t)){if(4===t.length){let e="#";for(let i=1;i<4;i+=1)e+=t.slice(i,i+1).concat(t.slice(i,i+1));t=e}const e=[];for(let i=1;i<7;i+=2)e.push(parseInt(`0x${t.slice(i,i+2)}`));return e.join(",")}return t}function r({val:e,model:i}){let o=e;if(e.isNaN())return{side:"no-one",vert:new t(0),base:new t(0),quote:new t(0)};i.Q0.eq(0)&&e.lt(i.i)&&(o=i.i),i.B0.eq(0)&&e.gt(i.i)&&(o=i.i);const r=i.getPriceDepth(o),n=r.baseAmount,l=r.quoteAmount,{isBuy:s}=r;return{side:s?"ask":"bid",vert:s?n:l,base:n,quote:l}}function n(e,i=1){return new t(i).div(e/2)}exports.baseZoomMultiples=1,exports.beforePriceImpactEffect=function({currentBaseMinAndZoomMultiples:e,targetPrice:i,midPrice:o,width:r}){const{baseMin:n,zoomMultiples:l}=e,s=new t(Math.log10(n.div(o).toNumber())),u=s.plus(2*l),a=new t(o.multipliedBy(10**u.toNumber()));if(i.gte(n)&&i.lte(a)){return{isSkip:!0,targetX:new t(Math.log10(i.div(o).toNumber())).minus(s).div(2*l).multipliedBy(r).toNumber(),baseMin:new t(0),zoomMultiples:1}}const m=new t(o.multipliedBy(.1)),p=new t(o.multipliedBy(10));if(i.gte(m)&&i.lte(p)){return{isSkip:!1,targetX:new t(Math.log10(i.div(o).toNumber())).minus(-1).div(2).multipliedBy(r).toNumber(),baseMin:m,zoomMultiples:1}}return{isSkip:!1,targetX:-1,baseMin:new t(0),zoomMultiples:1}},exports.chartOffsetYBCToolTip=18,exports.chartT=function(t,i){switch(t){case"depth-chart.tips.buy":return e.i18n._({id:"q+Q952",message:"Users pay {0} {1} and receive {2} {3}\\nPrice {4} ({5}%)",values:{0:i.amountText,1:i.baseTokenSymbol,2:i.oppositeAmountText,3:i.quoteTokenSymbol,4:i.priceText,5:i.slippageText}});case"depth-chart.tips.mid-price":return e.i18n._({id:"cnbRVW",message:"Initial Price {0} {1} = {2} {3}",values:{0:i.amountText,1:i.baseTokenSymbol,2:i.oppositeAmountText,3:i.quoteTokenSymbol}});case"depth-chart.tips.sell":return e.i18n._({id:"q+Q952",message:"Users pay {0} {1} and receive {2} {3}\\nPrice {4} ({5}%)",values:{0:i.oppositeAmountText,1:i.quoteTokenSymbol,2:i.amountText,3:i.baseTokenSymbol,4:i.priceText,5:i.slippageText}});case"pool.chart.buy-amount":return e.i18n._({id:"TaScUS",message:"Users sell {0} amount:",values:{0:i.symbol}});case"pool.chart.price-impact":return e.i18n._({id:"I0LXan",message:"Price Impact: {0}",values:{0:i.amount}});case"pool.chart.sell-amount":return e.i18n._({id:"F2vX4t",message:"Users buy {0} amount:",values:{0:i.symbol}});case"pool.create.disabled-token-amount":return e.i18n._({id:"5QDjef",message:"The token amount is calculated by initial price."});case"pool.create.set-pool.emulator.title":return e.i18n._({id:"FQfStS",message:"Emulator"});case"pool.create.set-pool.emulator.title.question":return e.i18n._({id:"9D2g7k",message:"The liquidity of DODO is continuous, which is different from the discrete liquidity of UniV3. The ticks shown in the illustration are for demonstration purposes only."});case"pool.chart.liquidity-chart-tip":return e.i18n._({id:"YvXHDU",message:"The area of the chart indicates the buy/sell volume of {0} that can be carried by the market when the current price changes to the hover price.",values:{0:i.baseTokenSymbol}});case"pool.chart.liquidity-chart-buy":return e.i18n._({id:"TvH4Ym",message:"Bought {0} {1}, price in the pool decreased to {2}",values:{0:i.amount,1:i.symbol,2:i.price}});case"pool.chart.liquidity-chart-sell":return e.i18n._({id:"0O1wzf",message:"Traders sold ‪{0}‬ {1}, price in the pool increased to {2}",values:{0:i.amount,1:i.symbol,2:i.price}});default:throw new Error(`Unknown key ${t}`)}},exports.colorRgb=o,exports.computeBaseAfterZoom=function({midPrice:e,zoomMultiples:t}){return e.multipliedBy(10**-t)},exports.computeBaseMinByDistance=function({dragDistance:e,prevBaseMin:i,chartWidth:o,zoomMultiples:r}){const l=n(o,r);return e>0?i.multipliedBy(1-l.multipliedBy(e).toNumber()):i.multipliedBy(10**l.multipliedBy(new t(e).abs()).plus(0).toNumber())},exports.computeBaseVert=function({midPrice:e,q:i,q0:o,pmmModel:r}){let n=t.maximum(i,o,r.B.multipliedBy(e));return n.isNaN()&&(n=new t(10)),n.eq(0)&&(n=new t(1)),{buyBaseVert:n.multipliedBy(1.2),sellBaseVert:n.div(e).multipliedBy(1.2)}},exports.computeTargetXByTargetPrice=function({type:e,targetPrice:i,midPrice:o,width:r}){if("sell"===e){return{zoomMultiples:new t(Math.log10(i.div(o).toNumber())).minus(0).div(3/4).abs(),targetX:r/2*(3/4)+r/2}}const n=new t(Math.log10(i.div(o).toNumber()));return{zoomMultiples:new t(0).minus(n).div(3/4).abs(),targetX:r/2*(1/4)}},exports.computeXPortion=n,exports.computeZoomMultiplesWhenZoom=function({prevZoomMultiples:e,zoomIn:t}){return!t&&e<=.1?e:t?e+.1:e-.1},exports.evalPoint=r,exports.labelPadding=12,exports.updateTooltip=function({tooltip:e,x:l,chartWidth:s,chartHeight:u,buyBaseVert:a,sellBaseVert:m,pmmModel:p,midPrice:c,baseTokenSymbol:d,quoteTokenSymbol:h,t:b,baseMinAndZoomMultiples:f,isHover:g,color:y,leftColor:x,rightColor:T}){const{zoomMultiples:v,baseMin:w}=f,B=n(s,v),M=a.div(u),k=m.div(u),q=2*v,S=w.multipliedBy(10**B.multipliedBy(l).toNumber());let N=new t(Math.log(c.div(w).toNumber())/Math.log(10));N=t.minimum(q,N),N=t.maximum(0,N);const P=N.div(B),X=r({val:S,model:p,midPrice:c});if(X.vert.isNaN())return;const A=S.lt(c);let O=u-X.vert.div(M).toNumber();A||(O=u-X.vert.div(k).toNumber());const _=i.formatShortNumber(S),z=i.formatShortNumber(X.vert),D=S.minus(c).abs().div(c).multipliedBy(100).toFixed(2),$=P.toNumber(),H=e.findOne("#toolTipVertLine"),L=e.findOne("#toolTipHoriLine"),U=e.findOne("#joinCircle"),V=e.findOne("#toolTip"),W=e.findOne("#priceTextLabel"),Y=e.findOne("#slippageTextLabel");if(!V)return;V.x(l),V.y(O-5-6);const Z=V.getText(),I=V.getTag();let j="ask"===X.side?i.formatShortNumber(X.quote):i.formatShortNumber(X.base);const C=p.k.lte(0);C&&(j=z);const F=i.formatShortNumber(c),Q={amountText:z,baseTokenSymbol:d,oppositeAmountText:j,quoteTokenSymbol:h,priceText:C?F:_,slippageText:`${A?"-":"+"}${D}`};if(P.minus(4).lte(l)&&P.plus(2).gte(l)&&g)Z.text(b("depth-chart.tips.mid-price",{amountText:1,baseTokenSymbol:d,oppositeAmountText:F,quoteTokenSymbol:h})),V.x($),V.y(u/2),null==H||H.hide(),null==L||L.hide(),null==U||U.hide(),null==W||W.hide(),null==Y||Y.hide();else{Z.text(A?b("depth-chart.tips.buy",{amountText:j,baseTokenSymbol:d,oppositeAmountText:z,quoteTokenSymbol:h,priceText:C?F:_,slippageText:`${A?"-":"+"}${D}`}):b("depth-chart.tips.sell",Q));const e=y||(A?"#55f6db":"#ff4f73"),t=A?x||"#55f6db":T||"#ff4f73";Z.fill(e),V.width()/2>l?(I.pointerDirection("left"),I.pointerHeight(15),I.pointerWidth(8),V.offsetX(-11),V.offsetY(-11)):V.width()/2+l>s?(I.pointerDirection("right"),I.pointerHeight(15),I.pointerWidth(8),V.offsetX(11),V.offsetY(-11)):(I.pointerDirection("down"),I.pointerHeight(8),I.pointerWidth(15),V.offsetX(0),V.offsetY(0)),null==H||H.points([l,u,l,O]),null==H||H.stroke(t),null==L||L.points(A?[l,O,$,O]:[$,O,l,O]),null==L||L.stroke(t),null==U||U.x(l),null==U||U.y(O),null==U||U.fill(A?x||"rgb(86, 246, 218)":T||"#FF5072"),null==U||U.stroke(A?x?`rgba(${o(x)}, 0.4)`:"rgba(86, 246, 218, 0.3)":T?`rgba(${o(T)}, 0.4)`:"rgba(255, 80, 114, 0.3)"),W&&(W.x(l),W.y(u),W.offsetX(W.width()/2),W.x()-W.width()/2<0?W.x(W.width()/2):W.x()+W.width()/2>s?W.x(s-W.width()/2):W.x(l));const i=null==W?void 0:W.findOne("#priceTextLabel-text");i&&(i.fill(e),i.text(_)),Y&&(Y.x(A?l+($-l)/2:l-(l-$)/2),Y.y(O),Y.offsetY(Y.height()/2),Y.offsetX(Y.width()/2));const r=null==Y?void 0:Y.findOne("#slippageTextLabel-text");r&&(r.fill(e),r.text(`${A?"-":"+"}${D}%`)),null==H||H.show(),null==L||L.show(),null==U||U.show(),null==W||W.show(),null==Y||Y.show()}e.show()};
@@ -0,0 +1 @@
1
+ "use strict";var e=require("@lingui/core"),t=require("bignumber.js"),i=require("./index-kkVP6Ex7.cjs");function o(e){let t=e.toLowerCase();if(t&&/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t)){if(4===t.length){let e="#";for(let i=1;i<4;i+=1)e+=t.slice(i,i+1).concat(t.slice(i,i+1));t=e}const e=[];for(let i=1;i<7;i+=2)e.push(parseInt(`0x${t.slice(i,i+2)}`));return e.join(",")}return t}function r({val:e,model:i}){let o=e;if(e.isNaN())return{side:"no-one",vert:new t(0),base:new t(0),quote:new t(0)};i.Q0.eq(0)&&e.lt(i.i)&&(o=i.i),i.B0.eq(0)&&e.gt(i.i)&&(o=i.i);const r=i.getPriceDepth(o),n=r.baseAmount,l=r.quoteAmount,{isBuy:s}=r;return{side:s?"ask":"bid",vert:s?n:l,base:n,quote:l}}function n(e,i=1){return new t(i).div(e/2)}exports.baseZoomMultiples=1,exports.beforePriceImpactEffect=function({currentBaseMinAndZoomMultiples:e,targetPrice:i,midPrice:o,width:r}){const{baseMin:n,zoomMultiples:l}=e,s=new t(Math.log10(n.div(o).toNumber())),u=s.plus(2*l),a=new t(o.multipliedBy(10**u.toNumber()));if(i.gte(n)&&i.lte(a)){return{isSkip:!0,targetX:new t(Math.log10(i.div(o).toNumber())).minus(s).div(2*l).multipliedBy(r).toNumber(),baseMin:new t(0),zoomMultiples:1}}const m=new t(o.multipliedBy(.1)),p=new t(o.multipliedBy(10));if(i.gte(m)&&i.lte(p)){return{isSkip:!1,targetX:new t(Math.log10(i.div(o).toNumber())).minus(-1).div(2).multipliedBy(r).toNumber(),baseMin:m,zoomMultiples:1}}return{isSkip:!1,targetX:-1,baseMin:new t(0),zoomMultiples:1}},exports.chartOffsetYBCToolTip=18,exports.chartT=function(t,i){switch(t){case"depth-chart.tips.buy":return e.i18n._({id:"q+Q952",message:"Users pay {0} {1} and receive {2} {3}\\nPrice {4} ({5}%)",values:{0:i.amountText,1:i.baseTokenSymbol,2:i.oppositeAmountText,3:i.quoteTokenSymbol,4:i.priceText,5:i.slippageText}});case"depth-chart.tips.mid-price":return e.i18n._({id:"cnbRVW",message:"Initial Price {0} {1} = {2} {3}",values:{0:i.amountText,1:i.baseTokenSymbol,2:i.oppositeAmountText,3:i.quoteTokenSymbol}});case"depth-chart.tips.sell":return e.i18n._({id:"q+Q952",message:"Users pay {0} {1} and receive {2} {3}\\nPrice {4} ({5}%)",values:{0:i.oppositeAmountText,1:i.quoteTokenSymbol,2:i.amountText,3:i.baseTokenSymbol,4:i.priceText,5:i.slippageText}});case"pool.chart.buy-amount":return e.i18n._({id:"TaScUS",message:"Users sell {0} amount:",values:{0:i.symbol}});case"pool.chart.price-impact":return e.i18n._({id:"I0LXan",message:"Price Impact: {0}",values:{0:i.amount}});case"pool.chart.sell-amount":return e.i18n._({id:"F2vX4t",message:"Users buy {0} amount:",values:{0:i.symbol}});case"pool.create.disabled-token-amount":return e.i18n._({id:"5QDjef",message:"The token amount is calculated by initial price."});case"pool.create.set-pool.emulator.title":return e.i18n._({id:"FQfStS",message:"Emulator"});case"pool.create.set-pool.emulator.title.question":return e.i18n._({id:"9D2g7k",message:"The liquidity of DODO is continuous, which is different from the discrete liquidity of UniV3. The ticks shown in the illustration are for demonstration purposes only."});case"pool.chart.liquidity-chart-tip":return e.i18n._({id:"YvXHDU",message:"The area of the chart indicates the buy/sell volume of {0} that can be carried by the market when the current price changes to the hover price.",values:{0:i.baseTokenSymbol}});case"pool.chart.liquidity-chart-buy":return e.i18n._({id:"TvH4Ym",message:"Bought {0} {1}, price in the pool decreased to {2}",values:{0:i.amount,1:i.symbol,2:i.price}});case"pool.chart.liquidity-chart-sell":return e.i18n._({id:"0O1wzf",message:"Traders sold ‪{0}‬ {1}, price in the pool increased to {2}",values:{0:i.amount,1:i.symbol,2:i.price}});default:throw new Error(`Unknown key ${t}`)}},exports.colorRgb=o,exports.computeBaseAfterZoom=function({midPrice:e,zoomMultiples:t}){return e.multipliedBy(10**-t)},exports.computeBaseMinByDistance=function({dragDistance:e,prevBaseMin:i,chartWidth:o,zoomMultiples:r}){const l=n(o,r);return e>0?i.multipliedBy(1-l.multipliedBy(e).toNumber()):i.multipliedBy(10**l.multipliedBy(new t(e).abs()).plus(0).toNumber())},exports.computeBaseVert=function({midPrice:e,q:i,q0:o,pmmModel:r}){let n=t.maximum(i,o,r.B.multipliedBy(e));return n.isNaN()&&(n=new t(10)),n.eq(0)&&(n=new t(1)),{buyBaseVert:n.multipliedBy(1.2),sellBaseVert:n.div(e).multipliedBy(1.2)}},exports.computeTargetXByTargetPrice=function({type:e,targetPrice:i,midPrice:o,width:r}){if("sell"===e){return{zoomMultiples:new t(Math.log10(i.div(o).toNumber())).minus(0).div(3/4).abs(),targetX:r/2*(3/4)+r/2}}const n=new t(Math.log10(i.div(o).toNumber()));return{zoomMultiples:new t(0).minus(n).div(3/4).abs(),targetX:r/2*(1/4)}},exports.computeXPortion=n,exports.computeZoomMultiplesWhenZoom=function({prevZoomMultiples:e,zoomIn:t}){return!t&&e<=.1?e:t?e+.1:e-.1},exports.evalPoint=r,exports.labelPadding=12,exports.updateTooltip=function({tooltip:e,x:l,chartWidth:s,chartHeight:u,buyBaseVert:a,sellBaseVert:m,pmmModel:p,midPrice:c,baseTokenSymbol:d,quoteTokenSymbol:h,t:b,baseMinAndZoomMultiples:f,isHover:g,color:y,leftColor:x,rightColor:T}){const{zoomMultiples:v,baseMin:w}=f,B=n(s,v),M=a.div(u),k=m.div(u),q=2*v,S=w.multipliedBy(10**B.multipliedBy(l).toNumber());let N=new t(Math.log(c.div(w).toNumber())/Math.log(10));N=t.minimum(q,N),N=t.maximum(0,N);const P=N.div(B),X=r({val:S,model:p,midPrice:c});if(X.vert.isNaN())return;const A=S.lt(c);let O=u-X.vert.div(M).toNumber();A||(O=u-X.vert.div(k).toNumber());const _=i.formatShortNumber(S),z=i.formatShortNumber(X.vert),D=S.minus(c).abs().div(c).multipliedBy(100).toFixed(2),$=P.toNumber(),H=e.findOne("#toolTipVertLine"),L=e.findOne("#toolTipHoriLine"),U=e.findOne("#joinCircle"),V=e.findOne("#toolTip"),W=e.findOne("#priceTextLabel"),Y=e.findOne("#slippageTextLabel");if(!V)return;V.x(l),V.y(O-5-6);const Z=V.getText(),I=V.getTag();let j="ask"===X.side?i.formatShortNumber(X.quote):i.formatShortNumber(X.base);const C=p.k.lte(0);C&&(j=z);const F=i.formatShortNumber(c),Q={amountText:z,baseTokenSymbol:d,oppositeAmountText:j,quoteTokenSymbol:h,priceText:C?F:_,slippageText:`${A?"-":"+"}${D}`};if(P.minus(4).lte(l)&&P.plus(2).gte(l)&&g)Z.text(b("depth-chart.tips.mid-price",{amountText:1,baseTokenSymbol:d,oppositeAmountText:F,quoteTokenSymbol:h})),V.x($),V.y(u/2),null==H||H.hide(),null==L||L.hide(),null==U||U.hide(),null==W||W.hide(),null==Y||Y.hide();else{Z.text(A?b("depth-chart.tips.buy",{amountText:j,baseTokenSymbol:d,oppositeAmountText:z,quoteTokenSymbol:h,priceText:C?F:_,slippageText:`${A?"-":"+"}${D}`}):b("depth-chart.tips.sell",Q));const e=y||(A?"#55f6db":"#ff4f73"),t=A?x||"#55f6db":T||"#ff4f73";Z.fill(e),V.width()/2>l?(I.pointerDirection("left"),I.pointerHeight(15),I.pointerWidth(8),V.offsetX(-11),V.offsetY(-11)):V.width()/2+l>s?(I.pointerDirection("right"),I.pointerHeight(15),I.pointerWidth(8),V.offsetX(11),V.offsetY(-11)):(I.pointerDirection("down"),I.pointerHeight(8),I.pointerWidth(15),V.offsetX(0),V.offsetY(0)),null==H||H.points([l,u,l,O]),null==H||H.stroke(t),null==L||L.points(A?[l,O,$,O]:[$,O,l,O]),null==L||L.stroke(t),null==U||U.x(l),null==U||U.y(O),null==U||U.fill(A?x||"rgb(86, 246, 218)":T||"#FF5072"),null==U||U.stroke(A?x?`rgba(${o(x)}, 0.4)`:"rgba(86, 246, 218, 0.3)":T?`rgba(${o(T)}, 0.4)`:"rgba(255, 80, 114, 0.3)"),W&&(W.x(l),W.y(u),W.offsetX(W.width()/2),W.x()-W.width()/2<0?W.x(W.width()/2):W.x()+W.width()/2>s?W.x(s-W.width()/2):W.x(l));const i=null==W?void 0:W.findOne("#priceTextLabel-text");i&&(i.fill(e),i.text(_)),Y&&(Y.x(A?l+($-l)/2:l-(l-$)/2),Y.y(O),Y.offsetY(Y.height()/2),Y.offsetX(Y.width()/2));const r=null==Y?void 0:Y.findOne("#slippageTextLabel-text");r&&(r.fill(e),r.text(`${A?"-":"+"}${D}%`)),null==H||H.show(),null==L||L.show(),null==U||U.show(),null==W||W.show(),null==Y||Y.show()}e.show()};
@@ -5,6 +5,7 @@ export interface ExecutionProps {
5
5
  onTxFail?: (error: Error, data: any) => void;
6
6
  onTxSubmit?: (tx: string, data: any) => void;
7
7
  onTxSuccess?: (tx: string, data: any) => void;
8
+ onTxReverted?: (tx: string, data: any) => void;
8
9
  executionStatus?: {
9
10
  showing?: Showing | null;
10
11
  showingDone?: boolean;
@@ -14,7 +15,7 @@ export interface ExecutionProps {
14
15
  closeShowing?: () => void;
15
16
  };
16
17
  }
17
- export default function useExecution({ onTxFail, onTxSubmit, onTxSuccess, }?: ExecutionProps): {
18
+ export default function useExecution({ onTxFail, onTxSubmit, onTxSuccess, onTxReverted, }?: ExecutionProps): {
18
19
  showing: Showing | null;
19
20
  showingDone: boolean;
20
21
  transactionTx: string;
@@ -1,6 +1,6 @@
1
1
  import { BigNumber as EthersBigNumber } from '@ethersproject/bignumber';
2
2
  import React from 'react';
3
- export default function useExecuteSwap(): ({ to, data, useSource, duration, ddl, gasLimit, subtitle, value, }: {
3
+ export default function useExecuteSwap(): ({ to, data, useSource, duration, ddl, gasLimit, subtitle, value, mixpanelProps, }: {
4
4
  value: string;
5
5
  to: string;
6
6
  data: string;
@@ -9,4 +9,5 @@ export default function useExecuteSwap(): ({ to, data, useSource, duration, ddl,
9
9
  ddl: number;
10
10
  gasLimit?: EthersBigNumber | undefined;
11
11
  subtitle: React.ReactNode;
12
+ mixpanelProps?: Record<string, any> | undefined;
12
13
  }) => void;
@@ -0,0 +1,12 @@
1
+ "use strict";var e=require("@emotion/styled"),t=require("lodash"),i=require("react"),r=require("./helper-DpUv3c8T.cjs"),n=require("react-konva"),o=require("./index-kkVP6Ex7.cjs"),s=require("bignumber.js"),l=require("@dodoex/api");require("@lingui/core"),require("@lingui/react"),require("@dodoex/icons"),require("react-dom"),require("react-redux"),require("identicon.js"),require("@web3-react/core"),require("@web3-react/eip1193"),require("@web3-react/walletconnect-v2"),require("@web3-react/metamask"),require("@web3-react/types"),require("@reduxjs/toolkit"),require("redux"),require("@tanstack/react-query"),require("react-window"),require("@ethersproject/bignumber"),require("dayjs"),require("axios"),require("zustand"),require("react-infinite-scroller"),require("recharts");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 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 h({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 p({width:e,targetLN10:t,minXLN10:i,maxXLN10:r}){return t.minus(i).div(r.minus(i)).multipliedBy(e).toNumber()}function c({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),h=[],p=[];let c=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))h.push({giveAmount:t,getAmount:new s(0),price:new s(0)});else{const e=i.div(t);h.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))p.push({giveAmount:t,getAmount:new s(0),price:new s(0)});else{const e=t.dividedBy(i);p.push({giveAmount:t,getAmount:i,price:e})}}if(h.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 j=[];for(let e=1;e<h.length;e++){const t=h[e],{giveAmount:i,getAmount:r,price:n}=t,o=h[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}),c=s.max(a,c)}}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],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=h.length>0?h[h.length-1]:p[0],A=p.length>0?p[0]:h[0],N=p.length>0?p[p.length-1]:h[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())),H=P.gt(0)?new s(Math.log10(P.toNumber())):new s(-Math.log10(y.toNumber()));const E=s.max(v.minus(S).abs(),H.minus(v).abs());return S=v.minus(E),H=v.plus(E),{leftStatAreaPoints:j,rightStatAreaPoints:b,maxLeftHeight:c.multipliedBy(1.2),maxRightHeight:x.multipliedBy(1.2),minXLN10:S,maxXLN10:H,middlePriceLN10:v}}),[e])}({params:u}),P=a-30.13,R=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),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=h({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=c({target:a.middlePrice}),s=p({minXLN10:N,maxXLN10:y,width:e,targetLN10:t}),l=g({maxHeight:x?j:b,gridAreaHeight:P,value:a.rectangleHeight}),m=n.findOne("#tooltip"),h=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"),H=n.findOne("#area");null==m||m.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)})),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==h||h.points([s,P,s,l]),null==h||h.stroke(x?"#55f6db":"#ff4f73");let E=x?"rgb(86, 246, 218)":"#FF5072",q=x?"rgba(86, 246, 218, 0.3)":"rgba(255, 80, 114, 0.3)";v.leftLine&&v.rightLine&&(E=x?v.leftLine:v.rightLine,q=x?`rgba(${r.colorRgb(v.leftLine)}, 0.4)`:`rgba(${r.colorRgb(v.rightLine)}, 0.4)`),L&&(L.x(s),L.y(l),L.fill(E),L.stroke(q)),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||(x?"#00FAD9":"#FF5072")),S.text(o.formatShortNumber(a.price)));const X=[];for(const t of u){const{middlePrice:i,rectangleHeight:r}=t,n=c({target:i}),o=p({minXLN10:N,maxXLN10:y,width:e,targetLN10:n}),s=g({maxHeight:x?j:b,gridAreaHeight:P,value:r});X.push(o,s+1)}const M=X.slice(),[k,B]=M;x?(M.push(s,l),M.push(s,P),M.push(k,P),M.push(k,B)):(M.unshift(k,P),M.unshift(s,P),M.unshift(s,l)),H&&(H.points(M),H.fill(x?v.leftLine||"#2c5b56":v.rightLine||"#7b3a48")),n.show()}}}},H=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}),E=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(h({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}),q=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:X,rightLine:M}=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=c({target:e}),m=p({minXLN10:r,maxXLN10:s,width:u,targetLN10:a}),h=g({maxHeight:l,gridAreaHeight:d,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,d),a.push(h,d),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: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=c({target:t}),m=p({minXLN10:r,maxXLN10:s,width:u,targetLN10:l}),h=g({maxHeight:a,gridAreaHeight:d,value:o});e.push(m,h),h<i&&(i=h)}const l=e.slice(),[h]=l;return l.unshift(h,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: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}),H,E,X,M,q]}),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(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})]})]});