@dodoex/widgets 2.6.12-beta.0 → 2.6.12-beta.2

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 (57) hide show
  1. package/dist/8de9a184d4ef0a11.svg +6 -0
  2. package/dist/cjs/8de9a184d4ef0a11.svg +6 -0
  3. package/dist/cjs/components/Confirm.d.ts +3 -2
  4. package/dist/cjs/components/ConnectWallet/NeedConnectButton.d.ts +1 -3
  5. package/dist/cjs/components/Swap/components/Dialog.d.ts +1 -0
  6. package/dist/cjs/components/Swap/components/TokenCard/TokenLogoCollapse.d.ts +2 -1
  7. package/dist/cjs/components/Swap/components/TokenCard/index.d.ts +2 -2
  8. package/dist/cjs/components/Swap/index.d.ts +4 -1
  9. package/dist/cjs/components/TokenLogo.d.ts +3 -1
  10. package/dist/cjs/constants/chains.d.ts +1 -0
  11. package/dist/cjs/{helper-Cto9FLzX.cjs → helper-AUp7J6va.cjs} +1 -1
  12. package/dist/cjs/hooks/Submission/types.d.ts +2 -0
  13. package/dist/cjs/hooks/Submission/useExecution.d.ts +2 -1
  14. package/dist/cjs/hooks/Swap/useExecuteSwap.d.ts +2 -1
  15. package/dist/cjs/{index-LuoRf91r.cjs → index-BKylx06q.cjs} +1 -1
  16. package/dist/cjs/{index-BprhI-s9.cjs → index-BVjmGGMM.cjs} +1 -1
  17. package/dist/cjs/index-CVLls_ja.cjs +53 -0
  18. package/dist/cjs/index.cjs +7 -7
  19. package/dist/cjs/index.d.ts +1 -0
  20. package/dist/cjs/{lottie-Cw1tUn46.cjs → lottie-DHOGwVb_.cjs} +1 -1
  21. package/dist/cjs/providers/GlobalConfigContext.d.ts +6 -2
  22. package/dist/cjs/src/components/Widget/index.d.ts +1 -0
  23. package/dist/cjs/src/constants/chains.d.ts +1 -2
  24. package/dist/cjs/src/hooks/ConnectWallet/TonConnect/index.d.ts +26 -0
  25. package/dist/cjs/src/hooks/ConnectWallet/useWalletState.d.ts +24 -0
  26. package/dist/cjs/src/hooks/Token/useInitTokenList.d.ts +3 -1
  27. package/dist/cjs/src/hooks/Widget/useInitPropsToRedux.d.ts +1 -1
  28. package/dist/cjs/src/hooks/contract/useFetchTokens.d.ts +1 -2
  29. package/dist/components/Confirm.d.ts +3 -2
  30. package/dist/components/ConnectWallet/NeedConnectButton.d.ts +1 -3
  31. package/dist/components/Swap/components/Dialog.d.ts +1 -0
  32. package/dist/components/Swap/components/TokenCard/TokenLogoCollapse.d.ts +2 -1
  33. package/dist/components/Swap/components/TokenCard/index.d.ts +2 -2
  34. package/dist/components/Swap/index.d.ts +4 -1
  35. package/dist/components/TokenLogo.d.ts +3 -1
  36. package/dist/constants/chains.d.ts +1 -0
  37. package/dist/{helper-ClCEnCKq.js → helper-CPPmdUet.js} +1 -1
  38. package/dist/hooks/Submission/types.d.ts +2 -0
  39. package/dist/hooks/Submission/useExecution.d.ts +2 -1
  40. package/dist/hooks/Swap/useExecuteSwap.d.ts +2 -1
  41. package/dist/index-C-UlcYP8.js +53 -0
  42. package/dist/{index-namICBzO.js → index-C4JHklNK.js} +1 -1
  43. package/dist/{index-B3zF3CfE.js → index-QEEiFrZ2.js} +1 -1
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +7 -7
  46. package/dist/{lottie-Cs4m17_U.js → lottie-CddNDjvd.js} +1 -1
  47. package/dist/providers/GlobalConfigContext.d.ts +6 -2
  48. package/dist/src/components/Widget/index.d.ts +1 -0
  49. package/dist/src/constants/chains.d.ts +1 -2
  50. package/dist/src/hooks/ConnectWallet/TonConnect/index.d.ts +26 -0
  51. package/dist/src/hooks/ConnectWallet/useWalletState.d.ts +24 -0
  52. package/dist/src/hooks/Token/useInitTokenList.d.ts +3 -1
  53. package/dist/src/hooks/Widget/useInitPropsToRedux.d.ts +1 -1
  54. package/dist/src/hooks/contract/useFetchTokens.d.ts +1 -2
  55. package/package.json +9 -2
  56. package/dist/cjs/index-Dyz2QYJX.cjs +0 -53
  57. package/dist/index-CK3jgZQ5.js +0 -53
@@ -1,5 +1,7 @@
1
- /// <reference types="react" />
2
1
  import { GraphQLRequests } from '@dodoex/api';
2
+ import React from 'react';
3
+ import { ConfirmProps } from '../components/Confirm';
4
+ import { DialogProps } from '../components/Swap/components/Dialog';
3
5
  import { TokenInfo } from '../hooks/Token';
4
6
  export interface GlobalFunctionConfig {
5
7
  widgetRef?: React.RefObject<HTMLDivElement>;
@@ -18,9 +20,11 @@ export interface GlobalFunctionConfig {
18
20
  chainId?: number;
19
21
  }) => string;
20
22
  graphQLRequests?: GraphQLRequests;
23
+ ConfirmComponent?: React.FunctionComponent<ConfirmProps>;
24
+ DialogComponent?: React.FunctionComponent<DialogProps>;
21
25
  }
22
26
  export declare const graphQLRequests: GraphQLRequests;
23
- export declare const GlobalConfigContext: import("react").Context<Omit<GlobalFunctionConfig, "graphQLRequests"> & {
27
+ export declare const GlobalConfigContext: React.Context<Omit<GlobalFunctionConfig, "graphQLRequests"> & {
24
28
  graphQLRequests: GraphQLRequests;
25
29
  }>;
26
30
  export declare const useGlobalConfig: () => Omit<GlobalFunctionConfig, "graphQLRequests"> & {
@@ -26,6 +26,7 @@ export interface WidgetProps extends Web3ConnectorsProps, InitTokenListProps, Ex
26
26
  apiServices?: Partial<APIServices>;
27
27
  crossChain?: boolean;
28
28
  noPowerBy?: boolean;
29
+ tonConnect?: boolean;
29
30
  onProviderChanged?: (provider?: any) => void;
30
31
  }
31
32
  export declare function Widget(props: PropsWithChildren<WidgetProps>): JSX.Element;
@@ -2,7 +2,6 @@ export declare enum ChainId {
2
2
  MAINNET = 1,
3
3
  GOERLI = 5,
4
4
  BSC = 56,
5
- SEPOLIA = 11155111,
6
5
  POLYGON = 137,
7
6
  ARBITRUM_ONE = 42161,
8
7
  AURORA = 1313161554,
@@ -15,7 +14,7 @@ export declare enum ChainId {
15
14
  SCROLL = 534352,
16
15
  MANTA = 169,
17
16
  MANTLE = 5000,
18
- DODO_CHAIN_TESTNET = 53457
17
+ TON = -239
19
18
  }
20
19
  export declare const rpcServerMap: {
21
20
  [key in ChainId]: Array<string>;
@@ -0,0 +1,26 @@
1
+ import { TonConnectUI } from '@tonconnect/ui';
2
+ import { TonClient, TonClient4 } from 'ton';
3
+ import BigNumber from 'bignumber.js';
4
+ /**
5
+ * https://ton-community.github.io/ton/modules.html
6
+ * https://ton-org.github.io/ton-core/modules.html
7
+ * https://toncenter.com/api/v2/
8
+ */
9
+ interface TonConnectState {
10
+ enabled: boolean;
11
+ client?: TonClient;
12
+ clientV4?: TonClient4;
13
+ tonConnectUI?: TonConnectUI;
14
+ connected?: {
15
+ chainId: number;
16
+ account: string;
17
+ };
18
+ initialize: () => void;
19
+ connect: () => Promise<void>;
20
+ getBlockNumber: () => Promise<number>;
21
+ getJettonWallet: (jettonMasterAddress: string) => Promise<string>;
22
+ getBalance: (account: string) => Promise<BigNumber>;
23
+ getTokenBalance: (jettonMasterAddress: string, decimals: number) => Promise<BigNumber>;
24
+ }
25
+ declare const useTonConnectStore: import("zustand").UseBoundStore<import("zustand").StoreApi<TonConnectState>>;
26
+ export default useTonConnectStore;
@@ -0,0 +1,24 @@
1
+ import BigNumber from 'bignumber.js';
2
+ export declare function useWalletState({ isTon, }?: {
3
+ isTon?: boolean;
4
+ }): {
5
+ isTon: boolean;
6
+ chainId: number | undefined;
7
+ account: string | undefined;
8
+ isMetamask: boolean;
9
+ autoConnect: (chainId?: number) => Promise<void>;
10
+ connect: () => Promise<void>;
11
+ getLastBlockNumber: () => Promise<number>;
12
+ getBalance: (account: string) => Promise<BigNumber>;
13
+ provider?: undefined;
14
+ } | {
15
+ isTon: boolean;
16
+ chainId: number | undefined;
17
+ account: string | undefined;
18
+ isMetamask: boolean | undefined;
19
+ autoConnect: (chainId?: number) => Promise<void>;
20
+ connect: () => void | Promise<void>;
21
+ provider: import("@ethersproject/providers").Web3Provider | undefined;
22
+ getLastBlockNumber: (() => Promise<number>) | undefined;
23
+ getBalance: ((account: string) => Promise<BigNumber | undefined>) | undefined;
24
+ };
@@ -3,4 +3,6 @@ export interface InitTokenListProps {
3
3
  tokenList?: TokenList | TokenListType;
4
4
  popularTokenList?: TokenList;
5
5
  }
6
- export default function useInitTokenList({ tokenList, popularTokenList, }: InitTokenListProps): void;
6
+ export default function useInitTokenList({ tokenList, popularTokenList, isTon, }: InitTokenListProps & {
7
+ isTon: boolean;
8
+ }): void;
@@ -1,2 +1,2 @@
1
1
  import { WidgetProps } from '../../components/Widget/';
2
- export declare function useInitPropsToRedux({ width, height, feeRate, rebateTo, colorMode, apikey, defaultChainId, defaultToToken, defaultFromToken, jsonRpcUrlMap, swapSlippage, bridgeSlippage, apiServices, crossChain, noPowerBy, }: WidgetProps): void;
2
+ export declare function useInitPropsToRedux({ width, height, feeRate, rebateTo, colorMode, apikey, defaultChainId, defaultToToken, defaultFromToken, jsonRpcUrlMap, swapSlippage, bridgeSlippage, apiServices, crossChain, noPowerBy, tonConnect, }: WidgetProps): void;
@@ -8,9 +8,8 @@ declare type TokenResult = {
8
8
  symbol?: string;
9
9
  name?: string;
10
10
  };
11
- export default function useFetchTokens({ tokenList, addresses: addressesProps, blockNumber, chainId, skip, }: {
11
+ export default function useFetchTokens({ tokenList, blockNumber, chainId, skip, }: {
12
12
  tokenList?: TokenList;
13
- addresses?: string[];
14
13
  blockNumber?: number;
15
14
  chainId?: number;
16
15
  skip?: boolean;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export default function Confirm({ open, onClose, title, children, singleBtn, danger, singleBtnText, cancelText, confirmText, disabledConfirm, confirmLoading, isManualClose, onConfirm, }: React.PropsWithChildren<{
2
+ export declare type ConfirmProps = React.PropsWithChildren<{
3
3
  open: boolean;
4
4
  onClose: () => void;
5
5
  title?: React.ReactNode;
@@ -12,4 +12,5 @@ export default function Confirm({ open, onClose, title, children, singleBtn, dan
12
12
  confirmLoading?: boolean;
13
13
  isManualClose?: boolean;
14
14
  onConfirm?: () => void;
15
- }>): JSX.Element;
15
+ }>;
16
+ export default function Confirm(props: ConfirmProps): JSX.Element;
@@ -1,10 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { ButtonProps } from '@dodoex/components';
3
3
  import { ChainId } from '@dodoex/api';
4
- export default function NeedConnectButton({ chainId, includeButton, showSwitchText, autoSwitch, ...props }: ButtonProps & {
4
+ export default function NeedConnectButton({ chainId, includeButton, ...props }: ButtonProps & {
5
5
  /** chainId that needs to be connected */
6
6
  chainId?: ChainId;
7
7
  includeButton?: boolean;
8
- showSwitchText?: boolean;
9
- autoSwitch?: boolean;
10
8
  }): JSX.Element;
@@ -2,6 +2,7 @@
2
2
  export declare const transitionTime = 300;
3
3
  export interface DialogProps {
4
4
  open: boolean;
5
+ id?: 'connect-wallet' | 'submission' | 'error-message' | 'select-chain' | 'select-token' | 'swap-summary' | 'swap-settings' | 'cross-chain-summary' | 'select-cross-chain' | 'pool-operate';
5
6
  onClose?: () => void;
6
7
  afterClose?: () => void;
7
8
  scope?: boolean;
@@ -1,8 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { TokenInfo } from '../../../../hooks/Token';
3
- export declare function TokenLogoCollapse({ token, onClick, showChainLogo, readonly, }: {
3
+ export declare function TokenLogoCollapse({ token, onClick, showChainLogo, readonly, showChainName: showChainNameProps, }: {
4
4
  token?: TokenInfo | null;
5
5
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
6
6
  showChainLogo?: boolean;
7
7
  readonly?: boolean;
8
+ showChainName?: boolean;
8
9
  }): JSX.Element;
@@ -22,7 +22,7 @@ export interface TokenCardProps {
22
22
  onTokenChange?: (token: TokenInfo, isOccupied: boolean) => void;
23
23
  side?: TokenPickerProps['side'];
24
24
  showChainLogo?: boolean;
25
- onlyCurrentChain?: boolean;
25
+ showChainName?: boolean;
26
26
  defaultLoadBalance?: boolean;
27
27
  overrideBalance?: BigNumber | null;
28
28
  overrideBalanceLoading?: boolean;
@@ -36,4 +36,4 @@ export interface TokenCardProps {
36
36
  }
37
37
  export declare function CardPlus(): JSX.Element;
38
38
  export declare function CardPlusConnected(): JSX.Element;
39
- export declare function TokenCard({ sx, amt, token, readOnly, showMaxBtn, canClickBalance, onMaxClick, fiatPriceTxt, occupiedAddrs, occupiedChainId, onInputFocus, onTokenClick, onInputChange, onTokenChange, side, showChainLogo, onlyCurrentChain, defaultLoadBalance, overrideBalance, overrideBalanceLoading, balanceText, showPercentage, inputReadonlyTooltip, inputTypography, chainId, hideToken, checkLogBalance, }: TokenCardProps): JSX.Element;
39
+ export declare function TokenCard({ sx, amt, token, readOnly, showMaxBtn, canClickBalance, onMaxClick, fiatPriceTxt, occupiedAddrs, occupiedChainId, onInputFocus, onTokenClick, onInputChange, onTokenChange, side, showChainLogo, showChainName, defaultLoadBalance, overrideBalance, overrideBalanceLoading, balanceText, showPercentage, inputReadonlyTooltip, inputTypography, chainId, hideToken, checkLogBalance, }: TokenCardProps): JSX.Element;
@@ -1,7 +1,10 @@
1
1
  /// <reference types="react" />
2
+ import { TokenInfo } from '../../hooks/Token/type';
2
3
  import { GetAutoSlippage } from '../../hooks/setting/useSetAutoSlippage';
3
4
  export interface SwapProps {
4
5
  /** Higher priority setting slippage */
5
6
  getAutoSlippage?: GetAutoSlippage;
7
+ onPayTokenChange?: (token: TokenInfo) => void;
8
+ onReceiveTokenChange?: (token: TokenInfo) => void;
6
9
  }
7
- export declare function Swap({ getAutoSlippage }?: SwapProps): JSX.Element;
10
+ export declare function Swap({ getAutoSlippage, onPayTokenChange, onReceiveTokenChange, }?: SwapProps): JSX.Element;
@@ -14,5 +14,7 @@ export interface TokenLogoProps {
14
14
  chainId?: number;
15
15
  noShowChain?: boolean;
16
16
  noBorder?: boolean;
17
+ chainSize?: number;
18
+ logoOffset?: number;
17
19
  }
18
- export default function TokenLogo({ width, height, marginRight, url, zIndex, cross, address: addressProps, token: tokenProps, sx, chainId, noShowChain, noBorder, }: TokenLogoProps): React.ReactElement;
20
+ export default function TokenLogo({ width, height, marginRight, url, zIndex, cross, address: addressProps, token: tokenProps, sx, chainId, noShowChain, noBorder, chainSize, logoOffset: logoOffsetProps, }: TokenLogoProps): React.ReactElement;
@@ -22,6 +22,7 @@ export declare const getRpcSingleUrlMap: (newRpcServerMap?: {
22
22
  534352: string;
23
23
  169: string;
24
24
  5000: string;
25
+ 53457: string;
25
26
  };
26
27
  export declare const platformIdMap: {
27
28
  [key in ChainId]: string;
@@ -1 +1 @@
1
- import{i18n as e}from"@lingui/core";import t from"bignumber.js";import{f as i}from"./index-CK3jgZQ5.js";function o(t,i){switch(t){case"depth-chart.tips.buy":return e._({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._({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._({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._({id:"TaScUS",message:"Users sell {0} amount:",values:{0:i.symbol}});case"pool.chart.price-impact":return e._({id:"I0LXan",message:"Price Impact: {0}",values:{0:i.amount}});case"pool.chart.sell-amount":return e._({id:"F2vX4t",message:"Users buy {0} amount:",values:{0:i.symbol}});case"pool.create.disabled-token-amount":return e._({id:"5QDjef",message:"The token amount is calculated by initial price."});case"pool.create.set-pool.emulator.title":return e._({id:"FQfStS",message:"Emulator"});case"pool.create.set-pool.emulator.title.question":return e._({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._({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._({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._({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}`)}}const l=12,n=18;function s(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 l=i.getPriceDepth(o),n=l.baseAmount,s=l.quoteAmount,{isBuy:r}=l;return{side:r?"ask":"bid",vert:r?n:s,base:n,quote:s}}function a({midPrice:e,q:i,q0:o,pmmModel:l}){let n=t.maximum(i,o,l.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)}}function u(e,i=1){return new t(i).div(e/2)}function m({tooltip:e,x:o,chartWidth:l,chartHeight:n,buyBaseVert:a,sellBaseVert:m,pmmModel:p,midPrice:d,baseTokenSymbol:c,quoteTokenSymbol:h,t:b,baseMinAndZoomMultiples:f,isHover:y,color:g,leftColor:T,rightColor:x}){const{zoomMultiples:v,baseMin:w}=f,k=u(l,v),M=a.div(n),B=m.div(n),q=2*v,S=w.multipliedBy(10**k.multipliedBy(o).toNumber());let N=new t(Math.log(d.div(w).toNumber())/Math.log(10));N=t.minimum(q,N),N=t.maximum(0,N);const P=N.div(k),X=r({val:S,model:p,midPrice:d});if(X.vert.isNaN())return;const A=S.lt(d);let _=n-X.vert.div(M).toNumber();A||(_=n-X.vert.div(B).toNumber());const z=i(S),O=i(X.vert),$=S.minus(d).abs().div(d).multipliedBy(100).toFixed(2),D=P.toNumber(),H=e.findOne("#toolTipVertLine"),L=e.findOne("#toolTipHoriLine"),U=e.findOne("#joinCircle"),V=e.findOne("#toolTip"),j=e.findOne("#priceTextLabel"),W=e.findOne("#slippageTextLabel");if(!V)return;V.x(o),V.y(_-5-6);const Y=V.getText(),F=V.getTag();let I="ask"===X.side?i(X.quote):i(X.base);const Q=p.k.lte(0);Q&&(I=O);const C=i(d),Z={amountText:O,baseTokenSymbol:c,oppositeAmountText:I,quoteTokenSymbol:h,priceText:Q?C:z,slippageText:`${A?"-":"+"}${$}`};if(P.minus(4).lte(o)&&P.plus(2).gte(o)&&y)Y.text(b("depth-chart.tips.mid-price",{amountText:1,baseTokenSymbol:c,oppositeAmountText:C,quoteTokenSymbol:h})),V.x(D),V.y(n/2),null==H||H.hide(),null==L||L.hide(),null==U||U.hide(),null==j||j.hide(),null==W||W.hide();else{Y.text(A?b("depth-chart.tips.buy",{amountText:I,baseTokenSymbol:c,oppositeAmountText:O,quoteTokenSymbol:h,priceText:Q?C:z,slippageText:`${A?"-":"+"}${$}`}):b("depth-chart.tips.sell",Z));const e=g||(A?"#55f6db":"#ff4f73"),t=A?T||"#55f6db":x||"#ff4f73";Y.fill(e),V.width()/2>o?(F.pointerDirection("left"),F.pointerHeight(15),F.pointerWidth(8),V.offsetX(-11),V.offsetY(-11)):V.width()/2+o>l?(F.pointerDirection("right"),F.pointerHeight(15),F.pointerWidth(8),V.offsetX(11),V.offsetY(-11)):(F.pointerDirection("down"),F.pointerHeight(8),F.pointerWidth(15),V.offsetX(0),V.offsetY(0)),null==H||H.points([o,n,o,_]),null==H||H.stroke(t),null==L||L.points(A?[o,_,D,_]:[D,_,o,_]),null==L||L.stroke(t),null==U||U.x(o),null==U||U.y(_),null==U||U.fill(A?T||"rgb(86, 246, 218)":x||"#FF5072"),null==U||U.stroke(A?T?`rgba(${s(T)}, 0.4)`:"rgba(86, 246, 218, 0.3)":x?`rgba(${s(x)}, 0.4)`:"rgba(255, 80, 114, 0.3)"),j&&(j.x(o),j.y(n),j.offsetX(j.width()/2),j.x()-j.width()/2<0?j.x(j.width()/2):j.x()+j.width()/2>l?j.x(l-j.width()/2):j.x(o));const i=null==j?void 0:j.findOne("#priceTextLabel-text");i&&(i.fill(e),i.text(z)),W&&(W.x(A?o+(D-o)/2:o-(o-D)/2),W.y(_),W.offsetY(W.height()/2),W.offsetX(W.width()/2));const r=null==W?void 0:W.findOne("#slippageTextLabel-text");r&&(r.fill(e),r.text(`${A?"-":"+"}${$}%`)),null==H||H.show(),null==L||L.show(),null==U||U.show(),null==j||j.show(),null==W||W.show()}e.show()}function p({dragDistance:e,prevBaseMin:i,chartWidth:o,zoomMultiples:l}){const n=u(o,l);return e>0?i.multipliedBy(1-n.multipliedBy(e).toNumber()):i.multipliedBy(10**n.multipliedBy(new t(e).abs()).plus(0).toNumber())}const d=1;function c({prevZoomMultiples:e,zoomIn:t}){return!t&&e<=.1?e:t?e+.1:e-.1}function h({type:e,targetPrice:i,midPrice:o,width:l}){if("sell"===e){return{zoomMultiples:new t(Math.log10(i.div(o).toNumber())).minus(0).div(3/4).abs(),targetX:l/2*(3/4)+l/2}}const n=new t(Math.log10(i.div(o).toNumber()));return{zoomMultiples:new t(0).minus(n).div(3/4).abs(),targetX:l/2*(1/4)}}function b({currentBaseMinAndZoomMultiples:e,targetPrice:i,midPrice:o,width:l}){const{baseMin:n,zoomMultiples:s}=e,r=new t(Math.log10(n.div(o).toNumber())),a=r.plus(2*s),u=new t(o.multipliedBy(10**a.toNumber()));if(i.gte(n)&&i.lte(u)){return{isSkip:!0,targetX:new t(Math.log10(i.div(o).toNumber())).minus(r).div(2*s).multipliedBy(l).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(l).toNumber(),baseMin:m,zoomMultiples:1}}return{isSkip:!1,targetX:-1,baseMin:new t(0),zoomMultiples:1}}function f({midPrice:e,zoomMultiples:t}){return e.multipliedBy(10**-t)}export{a,p as b,u as c,c as d,r as e,f,o as g,n as h,d as i,b as j,h as k,l,s as m,m as u};
1
+ import{i18n as e}from"@lingui/core";import t from"bignumber.js";import{f as i}from"./index-C-UlcYP8.js";function o(t,i){switch(t){case"depth-chart.tips.buy":return e._({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._({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._({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._({id:"TaScUS",message:"Users sell {0} amount:",values:{0:i.symbol}});case"pool.chart.price-impact":return e._({id:"I0LXan",message:"Price Impact: {0}",values:{0:i.amount}});case"pool.chart.sell-amount":return e._({id:"F2vX4t",message:"Users buy {0} amount:",values:{0:i.symbol}});case"pool.create.disabled-token-amount":return e._({id:"5QDjef",message:"The token amount is calculated by initial price."});case"pool.create.set-pool.emulator.title":return e._({id:"FQfStS",message:"Emulator"});case"pool.create.set-pool.emulator.title.question":return e._({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._({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._({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._({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}`)}}const l=12,n=18;function s(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 l=i.getPriceDepth(o),n=l.baseAmount,s=l.quoteAmount,{isBuy:r}=l;return{side:r?"ask":"bid",vert:r?n:s,base:n,quote:s}}function a({midPrice:e,q:i,q0:o,pmmModel:l}){let n=t.maximum(i,o,l.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)}}function u(e,i=1){return new t(i).div(e/2)}function m({tooltip:e,x:o,chartWidth:l,chartHeight:n,buyBaseVert:a,sellBaseVert:m,pmmModel:p,midPrice:d,baseTokenSymbol:c,quoteTokenSymbol:h,t:b,baseMinAndZoomMultiples:f,isHover:y,color:g,leftColor:T,rightColor:x}){const{zoomMultiples:v,baseMin:w}=f,k=u(l,v),M=a.div(n),B=m.div(n),q=2*v,S=w.multipliedBy(10**k.multipliedBy(o).toNumber());let N=new t(Math.log(d.div(w).toNumber())/Math.log(10));N=t.minimum(q,N),N=t.maximum(0,N);const P=N.div(k),X=r({val:S,model:p,midPrice:d});if(X.vert.isNaN())return;const A=S.lt(d);let _=n-X.vert.div(M).toNumber();A||(_=n-X.vert.div(B).toNumber());const z=i(S),O=i(X.vert),$=S.minus(d).abs().div(d).multipliedBy(100).toFixed(2),D=P.toNumber(),H=e.findOne("#toolTipVertLine"),L=e.findOne("#toolTipHoriLine"),U=e.findOne("#joinCircle"),V=e.findOne("#toolTip"),j=e.findOne("#priceTextLabel"),W=e.findOne("#slippageTextLabel");if(!V)return;V.x(o),V.y(_-5-6);const Y=V.getText(),F=V.getTag();let I="ask"===X.side?i(X.quote):i(X.base);const Q=p.k.lte(0);Q&&(I=O);const C=i(d),Z={amountText:O,baseTokenSymbol:c,oppositeAmountText:I,quoteTokenSymbol:h,priceText:Q?C:z,slippageText:`${A?"-":"+"}${$}`};if(P.minus(4).lte(o)&&P.plus(2).gte(o)&&y)Y.text(b("depth-chart.tips.mid-price",{amountText:1,baseTokenSymbol:c,oppositeAmountText:C,quoteTokenSymbol:h})),V.x(D),V.y(n/2),null==H||H.hide(),null==L||L.hide(),null==U||U.hide(),null==j||j.hide(),null==W||W.hide();else{Y.text(A?b("depth-chart.tips.buy",{amountText:I,baseTokenSymbol:c,oppositeAmountText:O,quoteTokenSymbol:h,priceText:Q?C:z,slippageText:`${A?"-":"+"}${$}`}):b("depth-chart.tips.sell",Z));const e=g||(A?"#55f6db":"#ff4f73"),t=A?T||"#55f6db":x||"#ff4f73";Y.fill(e),V.width()/2>o?(F.pointerDirection("left"),F.pointerHeight(15),F.pointerWidth(8),V.offsetX(-11),V.offsetY(-11)):V.width()/2+o>l?(F.pointerDirection("right"),F.pointerHeight(15),F.pointerWidth(8),V.offsetX(11),V.offsetY(-11)):(F.pointerDirection("down"),F.pointerHeight(8),F.pointerWidth(15),V.offsetX(0),V.offsetY(0)),null==H||H.points([o,n,o,_]),null==H||H.stroke(t),null==L||L.points(A?[o,_,D,_]:[D,_,o,_]),null==L||L.stroke(t),null==U||U.x(o),null==U||U.y(_),null==U||U.fill(A?T||"rgb(86, 246, 218)":x||"#FF5072"),null==U||U.stroke(A?T?`rgba(${s(T)}, 0.4)`:"rgba(86, 246, 218, 0.3)":x?`rgba(${s(x)}, 0.4)`:"rgba(255, 80, 114, 0.3)"),j&&(j.x(o),j.y(n),j.offsetX(j.width()/2),j.x()-j.width()/2<0?j.x(j.width()/2):j.x()+j.width()/2>l?j.x(l-j.width()/2):j.x(o));const i=null==j?void 0:j.findOne("#priceTextLabel-text");i&&(i.fill(e),i.text(z)),W&&(W.x(A?o+(D-o)/2:o-(o-D)/2),W.y(_),W.offsetY(W.height()/2),W.offsetX(W.width()/2));const r=null==W?void 0:W.findOne("#slippageTextLabel-text");r&&(r.fill(e),r.text(`${A?"-":"+"}${$}%`)),null==H||H.show(),null==L||L.show(),null==U||U.show(),null==j||j.show(),null==W||W.show()}e.show()}function p({dragDistance:e,prevBaseMin:i,chartWidth:o,zoomMultiples:l}){const n=u(o,l);return e>0?i.multipliedBy(1-n.multipliedBy(e).toNumber()):i.multipliedBy(10**n.multipliedBy(new t(e).abs()).plus(0).toNumber())}const d=1;function c({prevZoomMultiples:e,zoomIn:t}){return!t&&e<=.1?e:t?e+.1:e-.1}function h({type:e,targetPrice:i,midPrice:o,width:l}){if("sell"===e){return{zoomMultiples:new t(Math.log10(i.div(o).toNumber())).minus(0).div(3/4).abs(),targetX:l/2*(3/4)+l/2}}const n=new t(Math.log10(i.div(o).toNumber()));return{zoomMultiples:new t(0).minus(n).div(3/4).abs(),targetX:l/2*(1/4)}}function b({currentBaseMinAndZoomMultiples:e,targetPrice:i,midPrice:o,width:l}){const{baseMin:n,zoomMultiples:s}=e,r=new t(Math.log10(n.div(o).toNumber())),a=r.plus(2*s),u=new t(o.multipliedBy(10**a.toNumber()));if(i.gte(n)&&i.lte(u)){return{isSkip:!0,targetX:new t(Math.log10(i.div(o).toNumber())).minus(r).div(2*s).multipliedBy(l).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(l).toNumber(),baseMin:m,zoomMultiples:1}}return{isSkip:!1,targetX:-1,baseMin:new t(0),zoomMultiples:1}}function f({midPrice:e,zoomMultiples:t}){return e.multipliedBy(10**-t)}export{a,p as b,u as c,c as d,r as e,f,o as g,n as h,d as i,b as j,h as k,l,s as m,m as u};
@@ -8,6 +8,8 @@ export declare enum State {
8
8
  Warning = 3
9
9
  }
10
10
  export declare enum MetadataFlag {
11
+ swap = "swap",
12
+ crossChain = "crossChain",
11
13
  addLiquidity = "addLiquidity",
12
14
  removeLiquidity = "removeLiquidity",
13
15
  createDPPPool = "createDPPPool",
@@ -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;