@dodoex/widgets 3.0.4-ve33.8 → 3.1.0
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/cjs/locales/en-US.js +1 -1
- package/dist/cjs/locales/zh-CN.js +1 -1
- package/dist/{helper-DVYAzZqp.cjs → helper-Dnk7p0aW.cjs} +1 -1
- package/dist/{helper-m0zYAm2Y.js → helper-MNzHxcL-.js} +1 -1
- package/dist/index-BUQIlyE6.js +31 -0
- package/dist/index-BfNK29Ue.js +78 -0
- package/dist/{index-DVhV_6cf.cjs → index-BoZcs46K.cjs} +2 -2
- package/dist/{index-U8agSrk7.cjs → index-CeaQBk4G.cjs} +6 -6
- package/dist/{index-CnZH_7q3.js → index-D6YQnhH9.js} +1 -1
- package/dist/index-DYpT9qAx.cjs +31 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/types/components/AddressWithLinkAndCopy.d.ts +2 -1
- package/dist/types/components/List/EmptyList.d.ts +2 -1
- package/dist/types/components/SelectChain.d.ts +2 -1
- package/dist/types/components/Swap/components/ReviewDialog.d.ts +2 -1
- package/dist/types/components/Swap/components/SwapSettingsDialog/index.d.ts +4 -1
- package/dist/types/components/Swap/components/TokenCard/TokenPickerDialog.d.ts +3 -2
- package/dist/types/components/Swap/index.d.ts +4 -1
- package/dist/types/components/TokenLogoPair.d.ts +1 -1
- package/dist/types/components/Widget/index.d.ts +26 -2
- package/dist/types/components/WidgetContainer.d.ts +1 -1
- package/dist/types/constants/api.d.ts +1 -1
- package/dist/types/constants/swap.d.ts +0 -3
- package/dist/types/hooks/Swap/useFetchRoutePrice.d.ts +3 -1
- package/dist/types/hooks/Swap/useFetchRoutePrice.test.d.ts +1 -0
- package/dist/types/hooks/Swap/useSlippageLimit.d.ts +1 -1
- package/dist/types/hooks/Swap/useSwapSettingStore.d.ts +0 -1
- package/dist/types/hooks/contract/useFetchBlockNumber.d.ts +1 -1
- package/dist/types/hooks/useGlobalState.d.ts +32 -0
- package/dist/types/hooks/useGraphQLRequests.d.ts +1 -0
- package/dist/types/hooks/useTokenState.d.ts +18 -0
- package/dist/types/index.d.ts +26 -25
- package/dist/types/utils/formatter.d.ts +2 -2
- package/dist/types/widgets/MiningWidget/hooks/helper.d.ts +2 -2
- package/dist/types/widgets/MiningWidget/hooks/useReviewRewardToken.d.ts +2 -2
- package/dist/types/widgets/PoolWidget/AMMV3/hooks/usePools.d.ts +1 -1
- package/dist/types/widgets/PoolWidget/PoolCreate/components/BaseInfoCardList.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolCreate/components/FeeRateCard.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolCreate/components/LqRatioSet.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolCreate/components/LqSettingsShow.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolCreate/components/PriceModeCard.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolCreate/components/VersionChartExample.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolCreate/components/widgets.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolCreate/index.d.ts +3 -1
- package/dist/types/widgets/PoolWidget/PoolDetail/components/MoreDetail/index.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolDetail/components/Overview.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolDetail/components/TotalLiquidity.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolDetail/index.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolList/AddLiquidity.d.ts +6 -1
- package/dist/types/widgets/PoolWidget/PoolList/MyCreated.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolList/MyLiquidity.d.ts +6 -1
- package/dist/types/widgets/PoolWidget/PoolList/components/LiquidityTable.d.ts +3 -1
- package/dist/types/widgets/PoolWidget/PoolList/components/migationWidget.d.ts +7 -0
- package/dist/types/widgets/PoolWidget/PoolList/hooks/usePoolListFilterTokenAndPool.d.ts +9 -1
- package/dist/types/widgets/PoolWidget/PoolList/index.d.ts +7 -1
- package/dist/types/widgets/PoolWidget/PoolModify/index.d.ts +2 -1
- package/dist/types/widgets/PoolWidget/PoolOperate/PoolOperateInner.d.ts +4 -2
- package/dist/types/widgets/PoolWidget/PoolOperate/RemovePoolOperate.d.ts +4 -2
- package/dist/types/widgets/PoolWidget/PoolOperate/components/SlippageSetting.d.ts +1 -1
- package/dist/types/widgets/PoolWidget/PoolOperate/index.d.ts +4 -1
- package/dist/types/widgets/PoolWidget/PoolOperate/types.d.ts +12 -0
- package/dist/types/widgets/PoolWidget/hooks/usePoolDetail.d.ts +35 -0
- package/dist/types/widgets/PoolWidget/utils.d.ts +0 -1
- package/package.json +13 -14
- package/dist/index-Dwpantht.js +0 -78
- package/dist/index-IwdBiDvV.js +0 -32
- package/dist/index-ur0NgM_S.cjs +0 -32
- package/dist/types/store/actions/globals.d.ts +0 -9
- package/dist/types/store/actions/index.d.ts +0 -4
- package/dist/types/store/actions/settings.d.ts +0 -3
- package/dist/types/store/actions/token.d.ts +0 -7
- package/dist/types/store/actions/wallet.d.ts +0 -6
- package/dist/types/store/index.d.ts +0 -12
- package/dist/types/store/reducers/globals.d.ts +0 -21
- package/dist/types/store/reducers/index.d.ts +0 -17
- package/dist/types/store/reducers/settings.d.ts +0 -8
- package/dist/types/store/reducers/token.d.ts +0 -22
- package/dist/types/store/reducers/wallet.d.ts +0 -13
- package/dist/types/store/selectors/globals.d.ts +0 -7
- package/dist/types/store/selectors/settings.d.ts +0 -2
- package/dist/types/store/selectors/token.d.ts +0 -6
- package/dist/types/store/selectors/wallet.d.ts +0 -6
- package/dist/types/widgets/ve33/Ve33PoolList/TableList.d.ts +0 -13
- package/dist/types/widgets/ve33/Ve33PoolList/components/PoolTypeTag.d.ts +0 -7
- package/dist/types/widgets/ve33/Ve33PoolList/index.d.ts +0 -3
- package/dist/types/widgets/ve33/config.d.ts +0 -62
- package/dist/types/widgets/ve33/constants.d.ts +0 -21
- package/dist/types/widgets/ve33/hooks/usePoolColors.d.ts +0 -11
- package/dist/types/widgets/ve33/types.d.ts +0 -24
- package/dist/types/widgets/ve33/utils.d.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dodoex/widgets",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "DODO Widgets",
|
|
5
5
|
"source": "src/index.tsx",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"release": "semantic-release",
|
|
24
24
|
"release:local": "np --any-branch --no-cleanup --no-tests",
|
|
25
25
|
"release.npm-publish": "npm publish --access public",
|
|
26
|
-
"release.npm-publish-beta": "
|
|
26
|
+
"release.npm-publish-beta": "npm publish --tag beta",
|
|
27
27
|
"test": "jest src",
|
|
28
28
|
"test:e2e": "jest e2e"
|
|
29
29
|
},
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@babel/runtime": "^7.17.0",
|
|
61
|
-
"@dodoex/api": "3.0.
|
|
62
|
-
"@dodoex/components": "3.0.
|
|
61
|
+
"@dodoex/api": "3.0.3",
|
|
62
|
+
"@dodoex/components": "3.0.5",
|
|
63
63
|
"@dodoex/contract-request": "^1.3.0",
|
|
64
|
-
"@dodoex/dodo-contract-request": "1.
|
|
64
|
+
"@dodoex/dodo-contract-request": "1.15.0",
|
|
65
65
|
"@dodoex/icons": "^2.0.2",
|
|
66
66
|
"@emotion/react": "^11.10.0",
|
|
67
67
|
"@emotion/styled": "^11.10.0",
|
|
@@ -76,10 +76,10 @@
|
|
|
76
76
|
"@tanstack/react-query": "^5.18.1",
|
|
77
77
|
"@uniswap/sdk-core": "^5.9.0",
|
|
78
78
|
"@uniswap/v2-sdk": "^4.6.2",
|
|
79
|
-
"@web3-react/core": "
|
|
80
|
-
"@web3-react/eip1193": "
|
|
81
|
-
"@web3-react/metamask": "
|
|
82
|
-
"@web3-react/types": "
|
|
79
|
+
"@web3-react/core": "8.2.0",
|
|
80
|
+
"@web3-react/eip1193": "8.2.0",
|
|
81
|
+
"@web3-react/metamask": "8.2.1",
|
|
82
|
+
"@web3-react/types": "8.2.0",
|
|
83
83
|
"@web3-react/walletconnect-v2": "8.3.6",
|
|
84
84
|
"axios": "^0.27.2",
|
|
85
85
|
"bignumber.js": "^9.0.2",
|
|
@@ -101,14 +101,12 @@
|
|
|
101
101
|
"rmc-date-picker": "^6.0.10",
|
|
102
102
|
"semantic-release": "^19.0.2",
|
|
103
103
|
"tiny-invariant": "^1.1.0",
|
|
104
|
-
"zustand": "4.
|
|
104
|
+
"zustand": "^4.5.5"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
107
|
"@babel/runtime": ">=7.17.0",
|
|
108
108
|
"react": ">=17.0.1",
|
|
109
|
-
"react-dom": ">=17.0.1"
|
|
110
|
-
"react-redux": ">=7.2.2",
|
|
111
|
-
"redux": ">=4.1.2"
|
|
109
|
+
"react-dom": ">=17.0.1"
|
|
112
110
|
},
|
|
113
111
|
"devDependencies": {
|
|
114
112
|
"@babel/preset-env": "^7.16.11",
|
|
@@ -141,6 +139,7 @@
|
|
|
141
139
|
"babel-runtime": "^6.26.0",
|
|
142
140
|
"dotenv": "^16.0.2",
|
|
143
141
|
"ethers": "^5.7.1",
|
|
142
|
+
"gettext-parser": "^8.0.0",
|
|
144
143
|
"hardhat": "^2.22.13",
|
|
145
144
|
"identity-obj-proxy": "^3.0.0",
|
|
146
145
|
"jest": "^29.0.3",
|
|
@@ -154,4 +153,4 @@
|
|
|
154
153
|
"ts-jest": "^29.0.1",
|
|
155
154
|
"typescript": "^5.6.3"
|
|
156
155
|
}
|
|
157
|
-
}
|
|
156
|
+
}
|
package/dist/index-Dwpantht.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 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-m0zYAm2Y.js";import{f as O,j as X,a as T,b as A}from"./index-IwdBiDvV.js";import{solveQuadraticFunctionForTarget as q,PMMModel as W}from"@dodoex/api";import"@lingui/core";import"react-dom";import"@lingui/react";import"@dodoex/components";import"@web3-react/core";import"react-redux";import"axios";import"@ethersproject/bignumber";import"@reduxjs/toolkit";import"redux";import"@dodoex/dodo-contract-request";import"@tanstack/react-query";import"@web3-react/eip1193";import"@web3-react/walletconnect-v2";import"@web3-react/metamask";import"@web3-react/types";import"zustand";import"identicon.js";import"dayjs";import"react-transition-group";import"@dodoex/contract-request";import"react-window";import"jsbi";import"tiny-invariant";import"@uniswap/sdk-core";import"@uniswap/v2-sdk";import"react-infinite-scroller";import"recharts";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 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
|
-
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:K,horizontalLabelTextPoints:U}=function({chartHeight:t,chartWidth:e,xAxisPoints:i,oneXPx:o,baseMinAndZoomMultiples:r}){return l((()=>{const n=x(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:_,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=x(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=v({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=v({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 j=v({val:p.multipliedBy(10**h),model:n,midPrice:o});let w=e;const z=new t(h).div(g).toNumber();return j.vert.isNaN()||(w=e-j.vert.div(d).toNumber()),P&&u.length>=2&&(u.unshift(M,w),u.unshift(M,e)),u.push(z,w),f.lte(0)&&u.unshift(0,e),{quoteLinePoints:l,quoteLineAreaPoints:[0,e,0,y,...l],quoteLineAreaLinearGradientEndPointY:y,baseLinePoints:u,baseLineAreaPoints:[...u,z,e],baseLineAreaLinearGradientEndPointY:w,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=j({zoomIn:e,prevZoomMultiples:t.zoomMultiples});return{baseMin:w({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))),K.map(((t,e)=>X.jsx(g,{points:t,stroke:"#9d9d9d",strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},e))),U.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:_,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(""),[x,v]=a("-"),[y,z]=a("-"),[k,B]=a({baseMin:new t(0),zoomMultiples:C,targetMarginPriceX:0});n((()=>{void 0!==p&&B((t=>({baseMin:w({midPrice:p,zoomMultiples:t.zoomMultiples}),zoomMultiples:t.zoomMultiples,targetMarginPriceX:t.targetMarginPriceX})))}),[p]);const O=l((()=>o((({type:e,amount:o})=>{""===o&&p&&(B({baseMin:w({midPrice:p,zoomMultiples:C}),zoomMultiples:C,targetMarginPriceX:0}),"buy"===e?v("-"):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:w({midPrice:p,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}})),v(`${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:w({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=j({zoomIn:null!=t&&t,prevZoomMultiples:e.zoomMultiples});return{baseMin:w({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(_,{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:x})})]}),X.jsxs(nt,{borderColor:m&&m.grid,children:[L("pool.chart.sell-amount",{symbol:s}),X.jsx(_,{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(K,{})}),X.jsx(at,{onClick:()=>W(!0),children:X.jsx(U,{})}),X.jsx(at,{onClick:()=>q(!1),children:X.jsx(Q,{})})]})]})};export{ut as default};
|