@dodoex/widgets 3.0.2-pool.8 → 3.0.2-rise.1

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.
Files changed (51) hide show
  1. package/dist/cjs/locales/en-US.js +1 -1
  2. package/dist/cjs/locales/zh-CN.js +1 -1
  3. package/dist/{helper-FF_gOK8R.js → helper-Cn7LIi7f.js} +1 -1
  4. package/dist/{helper-BORa4cTY.cjs → helper-DmwmyAg2.cjs} +1 -1
  5. package/dist/index-5PCIiwtZ.js +78 -0
  6. package/dist/index-6fhZA_Cb.cjs +31 -0
  7. package/dist/{index-ljXTULBs.cjs → index-8M7lpUFg.cjs} +6 -6
  8. package/dist/{index-oaa0YrIj.js → index-BwMPShDW.js} +1 -1
  9. package/dist/index-C1T26jFv.js +31 -0
  10. package/dist/{index-C_TcX2Q5.cjs → index-C40xvoe0.cjs} +2 -2
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/locales/en-US.js +1 -1
  14. package/dist/locales/zh-CN.js +1 -1
  15. package/dist/types/components/AddressWithLinkAndCopy.d.ts +1 -2
  16. package/dist/types/components/Widget/index.d.ts +0 -19
  17. package/dist/types/components/WidgetContainer.d.ts +1 -1
  18. package/dist/types/store/actions/globals.d.ts +9 -0
  19. package/dist/types/store/actions/index.d.ts +4 -0
  20. package/dist/types/store/actions/settings.d.ts +3 -0
  21. package/dist/types/store/actions/token.d.ts +7 -0
  22. package/dist/types/store/actions/wallet.d.ts +6 -0
  23. package/dist/types/store/index.d.ts +12 -0
  24. package/dist/types/store/reducers/globals.d.ts +21 -0
  25. package/dist/types/store/reducers/index.d.ts +17 -0
  26. package/dist/types/store/reducers/settings.d.ts +8 -0
  27. package/dist/types/store/reducers/token.d.ts +22 -0
  28. package/dist/types/store/reducers/wallet.d.ts +13 -0
  29. package/dist/types/store/selectors/globals.d.ts +7 -0
  30. package/dist/types/store/selectors/settings.d.ts +2 -0
  31. package/dist/types/store/selectors/token.d.ts +6 -0
  32. package/dist/types/store/selectors/wallet.d.ts +6 -0
  33. package/dist/types/utils/address.d.ts +1 -1
  34. package/dist/types/utils/token.d.ts +1 -1
  35. package/dist/types/widgets/MiningWidget/hooks/helper.d.ts +2 -2
  36. package/dist/types/widgets/MiningWidget/hooks/useReviewRewardToken.d.ts +2 -2
  37. package/dist/types/widgets/PoolWidget/AMMV3/sdks/sdk-core/addresses.d.ts +0 -14
  38. package/dist/types/widgets/PoolWidget/AMMV3/sdks/sdk-core/chains.d.ts +6 -0
  39. package/dist/types/widgets/PoolWidget/PoolList/AddLiquidity.d.ts +1 -7
  40. package/dist/types/widgets/PoolWidget/PoolList/MyLiquidity.d.ts +1 -7
  41. package/dist/types/widgets/PoolWidget/PoolList/components/LiquidityTable.d.ts +1 -3
  42. package/dist/types/widgets/PoolWidget/PoolList/hooks/usePoolListFilterTokenAndPool.d.ts +1 -6
  43. package/dist/types/widgets/PoolWidget/PoolList/index.d.ts +1 -10
  44. package/dist/types/widgets/PoolWidget/hooks/usePoolDetail.d.ts +0 -35
  45. package/package.json +8 -5
  46. package/dist/index-B_XLbuDD.js +0 -78
  47. package/dist/index-BmsCOpVS.cjs +0 -31
  48. package/dist/index-DruH9xCi.js +0 -31
  49. package/dist/types/hooks/useGlobalState.d.ts +0 -32
  50. package/dist/types/hooks/useTokenState.d.ts +0 -18
  51. package/dist/types/widgets/PoolWidget/PoolList/components/migationWidget.d.ts +0 -7
@@ -0,0 +1,17 @@
1
+ import { State as settingsState } from './settings';
2
+ import { State as walletState } from './wallet';
3
+ import { State as tokenState } from './token';
4
+ import { State as globalState } from './globals';
5
+ export interface RootState {
6
+ settings: settingsState;
7
+ wallet: walletState;
8
+ token: tokenState;
9
+ globals: globalState;
10
+ }
11
+ declare const _default: () => import("redux").Reducer<import("redux").CombinedState<{
12
+ settings: settingsState;
13
+ wallet: walletState;
14
+ token: tokenState;
15
+ globals: globalState;
16
+ }>, import("redux").AnyAction>;
17
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { AnyAction } from 'redux';
2
+ export type Slippage = string | null;
3
+ export type State = {
4
+ slippage: Slippage;
5
+ };
6
+ export declare const initialState: State;
7
+ declare const _default: (state: State | undefined, action: AnyAction) => State;
8
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { AnyAction } from 'redux';
3
+ import type { TokenList } from '../../hooks/Token';
4
+ export type AccountBalance = {
5
+ tokenBalances?: BigNumber;
6
+ tokenAllowances?: BigNumber;
7
+ };
8
+ export type AccountBalances = {
9
+ [key in string]: AccountBalance;
10
+ };
11
+ export type SlippageWithToken = {
12
+ slippage: string;
13
+ tokens: string[];
14
+ };
15
+ export type State = {
16
+ tokenList: TokenList;
17
+ popularTokenList: TokenList;
18
+ slippageWithTokens: SlippageWithToken[];
19
+ };
20
+ export declare const initialState: State;
21
+ declare const _default: (state: State | undefined, action: AnyAction) => State;
22
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { AnyAction } from 'redux';
2
+ import { ChainId } from '@dodoex/api';
3
+ export type State = {
4
+ fromTokenChainId?: ChainId;
5
+ latestBlockNumber: number;
6
+ openConnectWalletInfo: boolean | {
7
+ /** Wallet is connected, chainID needs to be switched */
8
+ chainId?: ChainId;
9
+ };
10
+ };
11
+ export declare const initialState: State;
12
+ declare const _default: (state: State | undefined, action: AnyAction) => State;
13
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { RootState } from '../reducers';
2
+ export declare const getContractStatus: (state?: RootState) => import("../reducers/globals").ContractStatus | undefined;
3
+ export declare const getAutoConnectLoading: (state?: RootState) => boolean | undefined;
4
+ export declare const getAutoSlippage: (state?: RootState) => {
5
+ loading: boolean;
6
+ value: number | null;
7
+ } | undefined;
@@ -0,0 +1,2 @@
1
+ import { RootState } from '../reducers';
2
+ export declare const getSlippage: (state?: RootState) => import("../reducers/settings").Slippage;
@@ -0,0 +1,6 @@
1
+ import { ChainId } from '@dodoex/api';
2
+ import { RootState } from '../reducers';
3
+ export declare const getTokenList: (state?: RootState) => import("../../hooks/Token").TokenList;
4
+ export declare const getAllTokenList: (state?: RootState) => import("../../hooks/Token").TokenInfo[];
5
+ export declare const getPopularTokenList: (chainId: ChainId, state?: RootState) => import("../../hooks/Token").TokenInfo[];
6
+ export declare const getSlippageWithTokens: (state?: RootState) => import("../reducers/token").SlippageWithToken[];
@@ -0,0 +1,6 @@
1
+ import { RootState } from '../reducers';
2
+ export declare const getFromTokenChainId: (state?: RootState) => import("@dodoex/api").ChainId | undefined;
3
+ export declare const getLatestBlockNumber: (state?: RootState) => number;
4
+ export declare const getOpenConnectWalletInfo: (state?: RootState) => boolean | {
5
+ chainId?: import("@dodoex/api").ChainId;
6
+ };
@@ -23,7 +23,7 @@ export declare function openEtherscanPage(path: string | undefined, chainId: Cha
23
23
  * @returns
24
24
  * @see https://test-explorer.plumenetwork.xyz/address/0x3A7Bc5F9E41356728f037f17D88c642EE46d1Aaa?tab=contract
25
25
  */
26
- export declare const getUniInitCodeHash: (chainId: number) => "0x67a372377cf6d7f78cfdcc9df0bc21e1139bd49e5a47c33ee0de5389a4396410" | "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f" | "0x007722521498f3d29a63d1eb6ab35e202874706c77ce73d45c1ad9da88174a3f";
26
+ export declare const getUniInitCodeHash: (chainId: number) => "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f" | "0x007722521498f3d29a63d1eb6ab35e202874706c77ce73d45c1ad9da88174a3f" | "0x67a372377cf6d7f78cfdcc9df0bc21e1139bd49e5a47c33ee0de5389a4396410" | "0x2ebf1082215ab683deab4ee8ff50d42205db2059829b641717ab3f61f18d481a";
27
27
  export declare function sortsBefore(tokenA: TokenInfo, tokenB: TokenInfo): boolean;
28
28
  export declare const computePairAddress: ({ factoryAddress, tokenA, tokenB, fee, }: {
29
29
  factoryAddress: string;
@@ -19,7 +19,7 @@ export declare function getTokenPairCompareText({ fromToken, toToken, fromFiatPr
19
19
  comparePriceText: string;
20
20
  loading: boolean;
21
21
  };
22
- export declare function getShowDecimals(decimals: string | number): 6 | 4;
22
+ export declare function getShowDecimals(decimals: string | number): 4 | 6;
23
23
  export declare function convertFetchTokenToTokenInfo(token: {
24
24
  id?: string | null;
25
25
  address?: string | null;
@@ -60,10 +60,10 @@ export declare function getV3MiningSingleRewardAmount(t: ReviewedMiningRewardTok
60
60
  workThroughReward: BigNumber | undefined;
61
61
  lastFlagBlock: BigNumber | undefined;
62
62
  rewardVault: string | undefined;
63
+ startTime: BigNumber | undefined;
64
+ endTime: BigNumber | undefined;
63
65
  rewardPerBlock: BigNumber | undefined;
64
66
  startBlock: BigNumber | undefined;
65
67
  endBlock: BigNumber | undefined;
66
- startTime: BigNumber | undefined;
67
- endTime: BigNumber | undefined;
68
68
  };
69
69
  export {};
@@ -19,10 +19,10 @@ export declare function useReviewRewardToken({ chainId, index, miningContractAdd
19
19
  workThroughReward: BigNumber | undefined;
20
20
  lastFlagBlock: BigNumber | undefined;
21
21
  rewardVault: string | undefined;
22
+ startTime: BigNumber | undefined;
23
+ endTime: BigNumber | undefined;
22
24
  rewardPerBlock: BigNumber | undefined;
23
25
  startBlock: BigNumber | undefined;
24
26
  endBlock: BigNumber | undefined;
25
- startTime: BigNumber | undefined;
26
- endTime: BigNumber | undefined;
27
27
  };
28
28
  };
@@ -1,20 +1,6 @@
1
- import { SupportedChainsType } from './chains';
2
1
  type AddressMap = {
3
2
  [chainId: number]: string;
4
3
  };
5
- type ChainAddresses = {
6
- /**
7
- * UniswapV3Factory
8
- * @see https://taikoscan.io/address/0x78172691DD3B8ADa7aEbd9bFfB487FB11D735DB2?tab=contract#code
9
- */
10
- v3CoreFactoryAddress: string;
11
- /**
12
- * NonfungiblePositionManager
13
- * @see https://taikoscan.io/address/0x2623281DdcC34A73a9e8898f2c57A32A860903f1?tab=contract#code
14
- */
15
- nonfungiblePositionManagerAddress?: string;
16
- };
17
- export declare const CHAIN_TO_ADDRESSES_MAP: Record<SupportedChainsType, ChainAddresses>;
18
4
  export declare const V3_CORE_FACTORY_ADDRESSES: AddressMap;
19
5
  export declare const NONFUNGIBLE_POSITION_MANAGER_ADDRESSES: AddressMap;
20
6
  export {};
@@ -1,4 +1,10 @@
1
1
  import { ChainId } from '@dodoex/api';
2
2
  export { ChainId } from '@dodoex/api';
3
+ /**
4
+ * @deprecated
5
+ */
3
6
  export declare const SUPPORTED_CHAINS: readonly [ChainId.MAINNET, ChainId.ARBITRUM_ONE, ChainId.SEPOLIA, ChainId.TAIKO];
7
+ /**
8
+ * @deprecated
9
+ */
4
10
  export type SupportedChainsType = (typeof SUPPORTED_CHAINS)[number];
@@ -1,8 +1,7 @@
1
1
  import { ChainId } from '@dodoex/api';
2
2
  import React from 'react';
3
- import { TokenAndPoolFilterUserOptions } from './hooks/usePoolListFilterTokenAndPool';
4
3
  import { PoolOperateProps } from '../PoolOperate';
5
- export default function AddLiquidityList({ scrollParentRef, filterChainIds, activeChainId, handleChangeActiveChainId, operatePool, setOperatePool, tokenAndPoolFilter, getMigrationPairAndMining, }: {
4
+ export default function AddLiquidityList({ scrollParentRef, filterChainIds, activeChainId, handleChangeActiveChainId, operatePool, setOperatePool, }: {
6
5
  scrollParentRef: React.MutableRefObject<HTMLDivElement | null>;
7
6
  account?: string;
8
7
  filterChainIds?: ChainId[];
@@ -10,9 +9,4 @@ export default function AddLiquidityList({ scrollParentRef, filterChainIds, acti
10
9
  handleChangeActiveChainId: (chainId: number | undefined) => void;
11
10
  operatePool: Partial<PoolOperateProps> | null;
12
11
  setOperatePool: (operate: Partial<PoolOperateProps> | null) => void;
13
- tokenAndPoolFilter?: TokenAndPoolFilterUserOptions;
14
- getMigrationPairAndMining?: (p: {
15
- address: string;
16
- chainId: number;
17
- }) => void;
18
12
  }): JSX.Element;
@@ -1,16 +1,10 @@
1
1
  import { ChainId } from '@dodoex/api';
2
- import { TokenAndPoolFilterUserOptions } from './hooks/usePoolListFilterTokenAndPool';
3
2
  import { PoolOperateProps } from '../PoolOperate';
4
- export default function MyLiquidity({ account, filterChainIds, activeChainId, handleChangeActiveChainId, operatePool, setOperatePool, getMigrationPairAndMining, tokenAndPoolFilter, }: {
3
+ export default function MyLiquidity({ account, filterChainIds, activeChainId, handleChangeActiveChainId, operatePool, setOperatePool, }: {
5
4
  account?: string;
6
5
  filterChainIds?: ChainId[];
7
6
  activeChainId: ChainId | undefined;
8
7
  handleChangeActiveChainId: (chainId: number | undefined) => void;
9
8
  operatePool: Partial<PoolOperateProps> | null;
10
9
  setOperatePool: (operate: Partial<PoolOperateProps> | null) => void;
11
- getMigrationPairAndMining?: (p: {
12
- address: string;
13
- chainId: number;
14
- }) => void;
15
- tokenAndPoolFilter?: TokenAndPoolFilterUserOptions;
16
10
  }): JSX.Element;
@@ -1,7 +1,5 @@
1
1
  import { BoxProps } from '@dodoex/components';
2
- export default function LiquidityTable({ sx, children, empty, loading, hasMore, loadMore, loadMoreLoading, ...props }: BoxProps & {
3
- empty?: boolean;
4
- loading?: boolean;
2
+ export default function LiquidityTable({ sx, children, hasMore, loadMore, loadMoreLoading, ...props }: BoxProps & {
5
3
  hasMore?: boolean;
6
4
  loadMore?: () => void;
7
5
  loadMoreLoading?: boolean;
@@ -1,11 +1,6 @@
1
- import React from 'react';
2
1
  import { TokenInfo } from '../../../../hooks/Token';
3
2
  import { FetchLiquidityListLqList } from '../../utils';
4
- export interface TokenAndPoolFilterUserOptions {
5
- value: Array<TokenInfo>;
6
- element: React.ReactNode;
7
- }
8
- export declare function usePoolListFilterTokenAndPool(tokenAndPoolFilter?: TokenAndPoolFilterUserOptions): {
3
+ export declare function usePoolListFilterTokenAndPool(): {
9
4
  filterTokens: TokenInfo[];
10
5
  filterASymbol: string;
11
6
  filterBSymbol: string;
@@ -1,15 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Page, PageType } from '../../../router/types';
3
- import { PoolOperateProps } from '../PoolOperate';
4
- import { TokenAndPoolFilterUserOptions } from './hooks/usePoolListFilterTokenAndPool';
5
- export default function PoolList({ params, scrollRef: scrollParentRefProps, tokenAndPoolFilter, operatePMMPoolElement, onOperatePool, getMigrationPairAndMining, }: {
3
+ export default function PoolList({ params, scrollRef: scrollParentRefProps, }: {
6
4
  params?: Page<PageType.Pool>['params'];
7
5
  scrollRef?: React.RefObject<any>;
8
- tokenAndPoolFilter?: TokenAndPoolFilterUserOptions;
9
- operatePMMPoolElement?: React.ReactElement;
10
- onOperatePool?: (pool: Partial<PoolOperateProps> | null) => void;
11
- getMigrationPairAndMining?: (p: {
12
- address: string;
13
- chainId: number;
14
- }) => void;
15
6
  }): JSX.Element;
@@ -11,13 +11,6 @@ export declare function usePoolDetail({ id, chainId, }: {
11
11
  baseToken: TokenInfo;
12
12
  quoteToken: TokenInfo;
13
13
  miningAddress: string;
14
- apy: {
15
- miningBaseApy?: any | null;
16
- miningQuoteApy?: any | null;
17
- transactionBaseApy?: any | null;
18
- transactionQuoteApy?: any | null;
19
- metromMiningApy?: any | null;
20
- } | null | undefined;
21
14
  baseApy: string | undefined;
22
15
  quoteApy: string | undefined;
23
16
  isCpPool: boolean;
@@ -87,13 +80,6 @@ export declare function usePoolDetail({ id, chainId, }: {
87
80
  baseToken: TokenInfo;
88
81
  quoteToken: TokenInfo;
89
82
  miningAddress: string;
90
- apy: {
91
- miningBaseApy?: any | null;
92
- miningQuoteApy?: any | null;
93
- transactionBaseApy?: any | null;
94
- transactionQuoteApy?: any | null;
95
- metromMiningApy?: any | null;
96
- } | null | undefined;
97
83
  baseApy: string | undefined;
98
84
  quoteApy: string | undefined;
99
85
  isCpPool: boolean;
@@ -163,13 +149,6 @@ export declare function usePoolDetail({ id, chainId, }: {
163
149
  baseToken: TokenInfo;
164
150
  quoteToken: TokenInfo;
165
151
  miningAddress: string;
166
- apy: {
167
- miningBaseApy?: any | null;
168
- miningQuoteApy?: any | null;
169
- transactionBaseApy?: any | null;
170
- transactionQuoteApy?: any | null;
171
- metromMiningApy?: any | null;
172
- } | null | undefined;
173
152
  baseApy: string | undefined;
174
153
  quoteApy: string | undefined;
175
154
  isCpPool: boolean;
@@ -239,13 +218,6 @@ export declare function usePoolDetail({ id, chainId, }: {
239
218
  baseToken: TokenInfo;
240
219
  quoteToken: TokenInfo;
241
220
  miningAddress: string;
242
- apy: {
243
- miningBaseApy?: any | null;
244
- miningQuoteApy?: any | null;
245
- transactionBaseApy?: any | null;
246
- transactionQuoteApy?: any | null;
247
- metromMiningApy?: any | null;
248
- } | null | undefined;
249
221
  baseApy: string | undefined;
250
222
  quoteApy: string | undefined;
251
223
  isCpPool: boolean;
@@ -315,13 +287,6 @@ export declare function usePoolDetail({ id, chainId, }: {
315
287
  baseToken: TokenInfo;
316
288
  quoteToken: TokenInfo;
317
289
  miningAddress: string;
318
- apy: {
319
- miningBaseApy?: any | null;
320
- miningQuoteApy?: any | null;
321
- transactionBaseApy?: any | null;
322
- transactionQuoteApy?: any | null;
323
- metromMiningApy?: any | null;
324
- } | null | undefined;
325
290
  baseApy: string | undefined;
326
291
  quoteApy: string | undefined;
327
292
  isCpPool: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dodoex/widgets",
3
- "version": "3.0.2-pool.8",
3
+ "version": "3.0.2-rise.1",
4
4
  "description": "DODO Widgets",
5
5
  "source": "src/index.tsx",
6
6
  "types": "dist/types/index.d.ts",
@@ -58,10 +58,10 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@babel/runtime": "^7.17.0",
61
- "@dodoex/api": "3.0.3-morph.7",
61
+ "@dodoex/api": "3.0.3-rise.1",
62
62
  "@dodoex/components": "3.0.3",
63
63
  "@dodoex/contract-request": "^1.3.0",
64
- "@dodoex/dodo-contract-request": "^1.9.0-alpha.15",
64
+ "@dodoex/dodo-contract-request": "1.10.0-alpha.4",
65
65
  "@dodoex/icons": "^2.0.2",
66
66
  "@emotion/react": "^11.10.0",
67
67
  "@emotion/styled": "^11.10.0",
@@ -106,7 +106,9 @@
106
106
  "peerDependencies": {
107
107
  "@babel/runtime": ">=7.17.0",
108
108
  "react": ">=17.0.1",
109
- "react-dom": ">=17.0.1"
109
+ "react-dom": ">=17.0.1",
110
+ "react-redux": ">=7.2.2",
111
+ "redux": ">=4.1.2"
110
112
  },
111
113
  "devDependencies": {
112
114
  "@babel/preset-env": "^7.16.11",
@@ -152,4 +154,5 @@
152
154
  "ts-jest": "^29.0.1",
153
155
  "typescript": "^5.6.3"
154
156
  }
155
- }
157
+ }
158
+
@@ -1,78 +0,0 @@
1
- import e from"bignumber.js";import{merge as t,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-FF_gOK8R.js";import{f as O,j as X,a as T,b as A}from"./index-DruH9xCi.js";import{solveQuadraticFunctionForTarget as q,PMMModel as W}from"@dodoex/api";import"@lingui/core";import"@lingui/react";import"@dodoex/components";import"@dodoex/dodo-contract-request";import"identicon.js";import"zustand";import"@web3-react/core";import"@web3-react/eip1193";import"@web3-react/walletconnect-v2";import"@web3-react/metamask";import"@web3-react/types";import"@tanstack/react-query";import"react-dom";import"react-window";import"@ethersproject/bignumber";import"dayjs";import"react-transition-group";import"@dodoex/contract-request";import"axios";import"recharts";import"jsbi";import"tiny-invariant";import"@uniswap/sdk-core";import"@uniswap/v2-sdk";import"react-infinite-scroller";import"d3";import"rmc-date-picker";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(e,t){if(null==e)return{};var i,o,r=function(e,t){if(null==e)return{};var i,o,r={},n=Object.keys(e);for(o=0;o<n.length;o++)i=n[o],t.indexOf(i)>=0||(r[i]=e[i]);return r}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(o=0;o<n.length;o++)i=n[o],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function G(){return G=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[o])}return e},G.apply(this,arguments)}function D(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,o)}return i}function J(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?D(Object(i),!0).forEach((function(t){V(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):D(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function V(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var o=i.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Y(e){return e&&e.map(((e,t)=>r.createElement(e.tag,J({key:t},e.attr),Y(e.child))))}function I(e){return t=>r.createElement(R,G({attr:J({},e.attr)},t),Y(e.child))}function R(e){var t=t=>{var i,{attr:o,size:n,title:l}=e,s=Z(e,H),a=n||t.size||"1em";return t.className&&(i=t.className),e.className&&(i=(i?i+" ":"")+e.className),r.createElement("svg",G({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,o,s,{className:i,style:J(J({color:e.color||t.color},t.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),l&&r.createElement("title",null,l),e.children)};return void 0!==F?r.createElement(F.Consumer,null,(e=>t(e))):t(E)}function $(e){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:[]}]})(e)}function Q(e){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:[]}]})(e)}function K(e){return I({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M5 11h14v2H5z"},child:[]}]})(e)}function U(e){return I({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z"},child:[]}]})(e)}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:e})=>e&&c`
17
- border-color: red;
18
- `}
19
- }
20
- `;const ee="rgba(38, 39, 41, 0.3)";function te({width:o,height:r,midPrice:a,pmmModel:d,params:c,baseTokenSymbol:C,quoteTokenSymbol:S,baseMinAndZoomMultiples:N,colorMap:T,setBaseMinAndZoomMultiples:A}){const q=t({grid:"#2A2A2D",midPriceLine:"#313335",leftBg:[0,ee,1,"#31645d"],leftLine:"#55f6db",leftColor:"",rightBg:[0,ee,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:c.q,q0:c.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:e,chartWidth:t,horizontalLineCount:i,verticalLineCount:o}){return l((()=>{const r=[],n=e/(i+1),l=[],s=t/o;for(let e=0;e<i;e++){const i=n*(e+1);r.push([0,i,t,i])}for(let t=0;t<o;t++){const i=s*t+s/2;l.push([i,0,i,e])}return{horizontalGridLines:r,verticalGridLines:l}}),[e,t,i,o])}({chartHeight:E,chartWidth:W,horizontalLineCount:9,verticalLineCount:7}),{horizontalLabelTickPoints:K,horizontalLabelTextPoints:U}=function({chartHeight:e,chartWidth:t,xAxisPoints:i,oneXPx:o,baseMinAndZoomMultiples:r}){return l((()=>{const n=x(t,r.zoomMultiples),l=[],s=[];for(let t=0;t<i;t++){l.push([t*o+o/2,e,t*o+o/2,e+4]);const i=n.multipliedBy(t).multipliedBy(o).plus(n.multipliedBy(o/2)).toNumber(),a=r.baseMin.multipliedBy(10**i),d=t*o,c=e+2+4,u=O(a);s.push({x:d,y:c,text:u})}return{horizontalLabelTickPoints:l,horizontalLabelTextPoints:s}}),[r.baseMin,r.zoomMultiples,e,t,o,i])}({chartHeight:E,chartWidth:W,xAxisPoints:7,oneXPx:F,baseMinAndZoomMultiples:N}),{quoteLinePoints:_,quoteLineAreaPoints:te,quoteLineAreaLinearGradientEndPointY:ie,baseLinePoints:oe,baseLineAreaPoints:re,baseLineAreaLinearGradientEndPointY:ne,midPriceLinePoints:le}=function({chartHeight:t,chartWidth:i,midPrice:o,xPoints:r,pmmModel:n,baseMinAndZoomMultiples:s,buyYPortion:a,sellYPortion:d}){return l((()=>{const l=[],c=[],u=[],{baseMin:p,zoomMultiples:m}=s,g=x(i,m),h=2*m,b=new e(h).div(r);let f=new e(Math.log(o.div(p).toNumber())/Math.log(10));f=e.minimum(h,f),f=e.maximum(0,f);for(let i=new e(0);i.lte(f);){const e=p.multipliedBy(10**i.toNumber()),r=v({val:e,model:n,midPrice:o});if(!r.vert.isNaN()){const e=i.div(g).toNumber(),o=t-r.vert.div(a).toNumber();l.push(e,o)}i=i.plus(b)}for(let e=f;e.lte(h);){const i=p.multipliedBy(10**e.toNumber()),r=v({val:i,model:n,midPrice:o});if(!r.vert.isNaN()){const i=e.div(g).toNumber(),o=t-r.vert.div(d).toNumber();c.push(i,o)}e=e.plus(b)}const M=f.div(g).toNumber(),[,y]=l,P=n.k.eq(0);P&&l.push(M,y||t),l.push(M,t),u.push(M,t,M,0);const j=v({val:p.multipliedBy(10**h),model:n,midPrice:o});let w=t;const z=new e(h).div(g).toNumber();return j.vert.isNaN()||(w=t-j.vert.div(d).toNumber()),P&&c.length>=2&&(c.unshift(M,w),c.unshift(M,t)),c.push(z,w),f.lte(0)&&c.unshift(0,t),{quoteLinePoints:l,quoteLineAreaPoints:[0,t,0,y,...l],quoteLineAreaLinearGradientEndPointY:y,baseLinePoints:c,baseLineAreaPoints:[...c,z,t],baseLineAreaLinearGradientEndPointY:w,midPriceLinePoints:u}}),[s,i,r,o,n,t,a,d])}({chartHeight:E,chartWidth:W,midPrice:a,xPoints:50,pmmModel:d,baseMinAndZoomMultiples:N,buyYPortion:G,sellYPortion:D}),se=e=>{var t;const i=e.target;if(i&&Y){const e=null===(t=i.getStage())||void 0===t?void 0:t.getPointerPosition();if(e){const{x:t}=e;if(t>W)return void Y.hide();z({x:t,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})}}},ae=l((()=>i((e=>{const{target:t}=e,i=t.getStage();if(i){i.container().style.cursor="grabbing";const e=null==i?void 0:i.getPointerPosition();if(e){const t=e.x-I.current;I.current=e.x,R.current=e.x,A((e=>void 0===e.baseMin?e:{baseMin:P({dragDistance:t,prevBaseMin:e.baseMin,chartWidth:W,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:0}))}}}),100)),[W,A]),de=l((()=>i((e=>{e.cancelBubble=!0,e.evt.preventDefault();const t=e.evt.deltaY<0;A((e=>{const i=j({zoomIn:t,prevZoomMultiples:e.zoomMultiples});return{baseMin:w({midPrice:a,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:e.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(u,{ref:V,width:o,offsetY:-k,height:r+k,draggable:!0,dragBoundFunc:function(){return{x:this.absolutePosition().x,y:this.absolutePosition().y}},onMouseMove:se,onMouseOver:se,onMouseOut:()=>{Y&&Y.hide()},onDragStart:function(e){const{target:t}=e,i=t.getStage();if(i){const e=i.getPointerPosition();e&&(I.current=e.x)}},onDragMove:ae,onDragEnd:e=>{const{target:t}=e,i=t.getStage();i&&(i.container().style.cursor="pointer")},onWheel:de,children:[X.jsxs(p,{children:[X.jsx(m,{x:0,y:0,width:o,height:E,stroke:q.grid,strokeWidth:1}),$.map(((e,t)=>X.jsx(g,{points:e,stroke:q.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t))),Q.map(((e,t)=>X.jsx(g,{points:e,stroke:q.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t))),K.map(((e,t)=>X.jsx(g,{points:e,stroke:"#9d9d9d",strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t))),U.map(((e,t)=>X.jsx(h,{x:e.x,y:e.y,text:e.text,fontFamily:"Manrope",fontSize:12,fill:"#9d9d9d",width:F,padding:0,align:"center",verticalAlign:"bottom",listening:!1},t))),X.jsx(g,{points:te,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:E},fillLinearGradientEndPoint:{x:0,y:ie},fillLinearGradientColorStops:q.leftBg}),X.jsx(g,{points:_,stroke:q.leftLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),X.jsx(g,{points:re,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:W,y:E},fillLinearGradientEndPoint:{x:W,y:ne},fillLinearGradientColorStops:q.rightBg}),X.jsx(g,{points:oe,stroke:q.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),X.jsx(g,{points:le,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 ie=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
- `,oe=d.div`
33
- height: 100%;
34
- `,re=d.div`
35
- display: flex;
36
- align-items: center;
37
- `,ne=d.div`
38
- border: 1px solid ${({borderColor:e})=>e||"#2a2a2d"};
39
- flex: 1 0 50%;
40
-
41
- display: flex;
42
- align-items: center;
43
- justify-content: center;
44
- font-size: 12px;
45
- font-weight: 400;
46
- line-height: 17px;
47
- color: #606066;
48
-
49
- & + & {
50
- border-left: none;
51
- }
52
- `,le=d.span`
53
- color: #85858d;
54
- `,se=d.div`
55
- margin-top: 20px;
56
- display: flex;
57
- justify-content: center;
58
- margin-bottom: 9px;
59
- `,ae=d(ie)`
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 de({params:t,target:i,isBuy:o=!0}){const r=new e(t.b),n=new e(t.q);let l=new e(t.b0);const s=new e(t.q0),a=new e(t.i),d=new e(t.k),{R:c}=t;1===c&&l.eq(r)&&(l=q(r,n.minus(s),new e(1).div(a),d));const u=o?r.plus(i):r.minus(i);if(u.lt(l)||r.eq(l)){let t=l.multipliedBy(l).div(u).div(u);return t=new e(1).minus(d).plus(d.multipliedBy(t)),a.multipliedBy(t)}const p=new W;p.RStatus=c,p.B=r,p.B0=l,p.Q=n,p.Q0=s,p.i=a,p.k=d,p.mtFeeRate=new e(0),p.lpFeeRate=new e(0);let m=new e(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 e(1).minus(d).plus(d.multipliedBy(h)),a.div(h)}const ce=({chartId:t,width:i=834,height:r=460,baseTokenSymbol:s,quoteTokenSymbol:d,pmmModel:c,pmmParams:u,midPrice:p=new e(0),colorMap:m,notShowAmountInput:g})=>{(({id:e})=>{n((()=>{function t(e){e.preventDefault()}let i=!1;try{const e={get passive(){return i=!0,!1}};window.addEventListener("test",(()=>{}),e),window.removeEventListener("test",(()=>{}))}catch(e){i=!1}const o=document.getElementById(e),r=!!i&&{passive:!1};return null==o||o.addEventListener("wheel",t,r),()=>{null==o||o.removeEventListener("wheel",t)}}),[e])})({id:t});const[h,b]=a(""),[f,M]=a(""),[x,v]=a("-"),[y,z]=a("-"),[k,B]=a({baseMin:new e(0),zoomMultiples:C,targetMarginPriceX:0});n((()=>{void 0!==p&&B((e=>({baseMin:w({midPrice:p,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:e.targetMarginPriceX})))}),[p]);const O=l((()=>o((({type:t,amount:o})=>{""===o&&p&&(B({baseMin:w({midPrice:p,zoomMultiples:C}),zoomMultiples:C,targetMarginPriceX:0}),"buy"===t?v("-"):z("-"));const r=new e(o);if(!r.lte(0)&&!r.isNaN()&&(null==u?void 0:u.b)&&!r.gte(u.b)&&p)if("buy"===t){const e=de({params:u,target:r});B((o=>{const r=S({currentBaseMinAndZoomMultiples:o,targetPrice:e,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:t,targetPrice:e}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:w({midPrice:p,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}})),v(`${T({input:e.minus(p).div(p)})}`)}else{const e=function({params:e,target:t}){return de({params:e,target:t,isBuy:!1})}({params:u,target:r});B((o=>{const r=S({currentBaseMinAndZoomMultiples:o,targetPrice:e,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:t,targetPrice:e}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:w({midPrice:p,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}})),z(`+${T({input:e.minus(p).div(p)})}`)}}),300)),[u,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=e=>{let t=0;t=e?-.1*i:.1*i,B((e=>void 0===e.baseMin?e:{baseMin:P({dragDistance:t,prevBaseMin:e.baseMin,chartWidth:i,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:e.targetMarginPriceX}))},W=e=>{B((t=>{const i=j({zoomIn:null!=e&&e,prevZoomMultiples:t.zoomMultiples});return{baseMin:w({midPrice:p,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:t.targetMarginPriceX}}))},E=l((()=>{if(""===h)return!1;const t=new e(h);return!(!t.lte(0)&&!t.isNaN()&&(null==u?void 0:u.b)&&!t.gte(u.b))}),[h,u]),F=l((()=>{if(""===f)return!1;const t=new e(f);return!(!t.lte(0)&&!t.isNaN()&&(null==u?void 0:u.b)&&!t.gte(u.b))}),[f,u]);return X.jsxs(oe,{id:t,children:[g?"":X.jsxs(re,{children:[X.jsxs(ne,{borderColor:m&&m.grid,children:[L("pool.chart.buy-amount",{symbol:s}),X.jsx(_,{value:h,error:E,onChange:e=>{const t=A(e.target.value,2);null!==t&&b(t)}}),X.jsx(le,{children:L("pool.chart.price-impact",{amount:x})})]}),X.jsxs(ne,{borderColor:m&&m.grid,children:[L("pool.chart.sell-amount",{symbol:s}),X.jsx(_,{value:f,error:F,onChange:e=>{const t=A(e.target.value,2);null!==t&&M(t)}}),X.jsx(le,{children:L("pool.chart.price-impact",{amount:y})})]})]}),void 0!==u&&void 0!==p&&void 0!==c&&void 0!==k.baseMin&&void 0!==p&&X.jsx(te,{width:i,height:r,params:u,midPrice:p,pmmModel:c,baseTokenSymbol:s,quoteTokenSymbol:d,baseMinAndZoomMultiples:k,colorMap:m,setBaseMinAndZoomMultiples:B}),X.jsxs(se,{className:"operate-btn-wrapper",children:[X.jsx(ae,{onClick:()=>q(!0),children:X.jsx($,{})}),X.jsx(ae,{onClick:()=>W(!1),children:X.jsx(K,{})}),X.jsx(ae,{onClick:()=>W(!0),children:X.jsx(U,{})}),X.jsx(ae,{onClick:()=>q(!1),children:X.jsx(Q,{})})]})]})};export{ce as default};