@dodoex/widgets 2.1.0 → 2.2.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/index.cjs +1 -1
- package/dist/cjs/locales/en-US.js +1 -1
- package/dist/cjs/src/components/Swap/components/ReviewDialog.d.ts +4 -3
- package/dist/cjs/src/components/Swap/components/TokenCard/NumberInput.d.ts +2 -1
- package/dist/cjs/src/components/Swap/components/TokenCard/index.d.ts +3 -1
- package/dist/cjs/src/hooks/Swap/useExecuteSwap.d.ts +2 -4
- package/dist/cjs/src/hooks/Swap/useFetchRoutePrice.d.ts +3 -2
- package/dist/cjs/src/hooks/Swap/useMarginAmount.d.ts +3 -3
- package/dist/cjs/src/store/index.d.ts +1 -1
- package/dist/cjs/src/store/reducers/globals.d.ts +12 -2
- package/dist/cjs/src/store/reducers/index.d.ts +1 -1
- package/dist/cjs/src/store/reducers/token.d.ts +5 -2
- package/dist/cjs/src/store/selectors/globals.d.ts +1 -1
- package/dist/cjs/src/store/selectors/token.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/src/components/Swap/components/ReviewDialog.d.ts +4 -3
- package/dist/src/components/Swap/components/TokenCard/NumberInput.d.ts +2 -1
- package/dist/src/components/Swap/components/TokenCard/index.d.ts +3 -1
- package/dist/src/hooks/Swap/useExecuteSwap.d.ts +2 -4
- package/dist/src/hooks/Swap/useFetchRoutePrice.d.ts +3 -2
- package/dist/src/hooks/Swap/useMarginAmount.d.ts +3 -3
- package/dist/src/store/index.d.ts +1 -1
- package/dist/src/store/reducers/globals.d.ts +12 -2
- package/dist/src/store/reducers/index.d.ts +1 -1
- package/dist/src/store/reducers/token.d.ts +5 -2
- package/dist/src/store/selectors/globals.d.ts +1 -1
- package/dist/src/store/selectors/token.d.ts +5 -5
- package/package.json +1 -1
|
@@ -12,6 +12,9 @@ export declare type SlippageWithToken = {
|
|
|
12
12
|
slippage: string;
|
|
13
13
|
tokens: string[];
|
|
14
14
|
};
|
|
15
|
+
export interface DefaultTokenInfo extends TokenInfo {
|
|
16
|
+
amount?: number;
|
|
17
|
+
}
|
|
15
18
|
export declare type State = {
|
|
16
19
|
tokenList: TokenList;
|
|
17
20
|
popularTokenList: TokenList;
|
|
@@ -21,8 +24,8 @@ export declare type State = {
|
|
|
21
24
|
[key in string]: boolean;
|
|
22
25
|
};
|
|
23
26
|
slippageWithTokens: SlippageWithToken[];
|
|
24
|
-
defaultFromToken?:
|
|
25
|
-
defaultToToken?:
|
|
27
|
+
defaultFromToken?: DefaultTokenInfo;
|
|
28
|
+
defaultToToken?: DefaultTokenInfo;
|
|
26
29
|
};
|
|
27
30
|
export declare const initialState: State;
|
|
28
31
|
declare const _default: (state: State | undefined, action: AnyAction) => State;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RootState } from '../reducers';
|
|
2
|
-
export declare const getGlobalProps: (state?: RootState) => import("
|
|
2
|
+
export declare const getGlobalProps: (state?: RootState) => import("../reducers/globals").State;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { ChainId } from '../../constants/chains';
|
|
3
|
-
import {
|
|
3
|
+
import { DefaultTokenInfo } from '../reducers/token';
|
|
4
4
|
import { RootState } from '../reducers';
|
|
5
|
-
export declare const getTokenList: (state?: RootState) => import("../../hooks/Token
|
|
6
|
-
export declare const getPopularTokenList: (chainId: ChainId, state?: RootState) => TokenInfo[];
|
|
5
|
+
export declare const getTokenList: (state?: RootState) => import("../../hooks/Token").TokenList;
|
|
6
|
+
export declare const getPopularTokenList: (chainId: ChainId, state?: RootState) => import("../../hooks/Token").TokenInfo[];
|
|
7
7
|
export declare const getSlippageWithTokens: (state?: RootState) => import("../reducers/token").SlippageWithToken[];
|
|
8
8
|
export declare const getAccountBalances: (state?: RootState) => import("../reducers/token").AccountBalances;
|
|
9
9
|
export declare const getEthBalance: (state?: RootState) => BigNumber;
|
|
10
|
-
export declare const getDefaultFromToken: (state?: RootState) =>
|
|
11
|
-
export declare const getDefaultToToken: (state?: RootState) =>
|
|
10
|
+
export declare const getDefaultFromToken: (state?: RootState) => DefaultTokenInfo | undefined;
|
|
11
|
+
export declare const getDefaultToToken: (state?: RootState) => DefaultTokenInfo | undefined;
|
|
12
12
|
export declare const getTokenBalance: (tokenAddress: string, state?: RootState) => BigNumber;
|
|
13
13
|
export declare const getTokenAllowance: (tokenAddress: string, state?: RootState) => void;
|
|
14
14
|
export declare const getBalanceLoadings: (state?: RootState) => {
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Trans as e,I18nProvider as t}from"@lingui/react";import n,{BigNumber as o}from"bignumber.js";import{chunk as i,debounce as r}from"lodash";import{Box as a,useTheme as s,BaseButton as l,Input as c,SearchInput as d,Button as u,HoverOpacity as p,createTheme as m,ThemeProvider as h,CssBaseline as f,QuestionTooltip as g,RotatingIcon as b}from"@dodoex/components";import{getAddress as y}from"@ethersproject/address";import*as x from"react";import{useState as v,useMemo as E,useCallback as w,useEffect as C,useRef as A,useContext as O,createContext as k}from"react";import{useDispatch as T,useSelector as I,Provider as L}from"react-redux";import{CaretUp as R,Error as S,ErrorWarn as D,DoneBorder as N,ArrowTopRightBorder as _,ArrowBack as B,DoubleRight as P,DetailBorder as F,Done as j,Warn as M,Switch as U,Setting as H,Dodo as W}from"@dodoex/icons";import $ from"identicon.js";import{useWeb3React as V,initializeConnector as z,Web3ReactProvider as K}from"@web3-react/core";import{configureStore as G}from"@reduxjs/toolkit";import{combineReducers as Y}from"redux";import{Contract as q}from"@ethersproject/contracts";import{AddressZero as X}from"@ethersproject/constants";import{defaultAbiCoder as Z,Interface as Q}from"@ethersproject/abi";import{EIP1193 as J}from"@web3-react/eip1193";import{WalletConnect as ee}from"@web3-react/walletconnect";import{MetaMask as te}from"@web3-react/metamask";import{JsonRpcProvider as ne}from"@ethersproject/providers";import{Connector as oe}from"@web3-react/types";import{jsxs as ie,jsx as re,Fragment as ae}from"react/jsx-runtime";import{i18n as se}from"@lingui/core";import{VariableSizeList as le}from"react-window";import{en as ce,zh as de}from"make-plural/plurals";import ue from"axios";import{BigNumber as pe,parseFixed as me}from"@ethersproject/bignumber";import{createRoot as he}from"react-dom/client";function fe({input:e,showDecimals:t=4,showPrecisionDecimals:n=2,showIntegerOnly:i=!1,showDecimalsOnly:r=!1,noGroupSeparator:a=!1}){const s=new o(e);if(s.isNaN())return"-";let l=s.dp(t,o.ROUND_DOWN);return l.eq(0)&&(s.gt(0)||s.lt(0))&&(l=s.sd(null!=n?n:t,o.ROUND_DOWN)),i&&(l=l.integerValue(o.ROUND_DOWN)),r&&(l=l.minus(l.integerValue(o.ROUND_DOWN))),a?l.toFormat({decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0}):l.toFormat()}function ge({input:e,decimals:t,showPrecisionDecimals:n=2,noGroupSeparator:i}){if(null==e)return"-";const r=new o(e);if(r.isNaN())return"-";return fe({input:r,showDecimals:void 0===t?0:t>6?6:t>4?4:t,showPrecisionDecimals:n,noGroupSeparator:i})}function be(e){if("number"==typeof e)return be(new o(e));if(e.isNaN())return"NaN";if(e.isNegative())return`-${be(e.negated())}`;if(e.isZero())return"0";let t=e.integerValue(o.ROUND_FLOOR),n=e.minus(t),i="";for(;!t.isZero();){i=t.modulo(10).toString().toString()+i,t=t.idiv(10)}if(""===i&&(i="0"),n.isZero())return i;i+=".";let r=0;for(;!n.isZero()&&r<100;){const e=n.times(10),t=e.integerValue(o.ROUND_FLOOR);i+=t.toString(),n=e.minus(t),r+=1}return i}const ye=(e,t)=>{if("string"==typeof e&&!e.match(/[-+]?\d+(.+d+)?/))return e;const n=new o(e);if(t){let e=n.toFixed(t,o.ROUND_DOWN);return new o(e).isZero()&&(e=be(n.precision(t,o.ROUND_DOWN))),e}return be(n)},xe=(e,t)=>{let n=e;const o=n.match("[0-9。.]+");n=o&&o.length>0?o[0]:"",n=n.replace("。",".");let i=0;if(n){const e=n.split("."),t=0===e[0].length?["0"]:[e[0]];e.length>1?t[1]=e.slice(1,e.length).join(""):t[0].length>1&&"0"===t[0][0]&&(t[0]=t[0].slice(1,t[0].length)),t.length>1&&(i=t[1].length),n=t.join(".")}return t>=0&&i>t?ye(n,t):n},ve=(e,t,n)=>{const i=new o(e).times(new o(10).pow(t));return n?i:i.dp(0)},Ee=(e,t)=>{if(0===e.length||0===t.length)return!1;if(t.length===e.length)return e.toLowerCase()===t.toLowerCase();const n=e.substring(2,e.length).toLowerCase(),o=t.substring(2,t.length).toLowerCase();return n.length>o.length?n.endsWith(o):o.endsWith(n)};const we=e=>{const t={isMainnet:1===e,isRinkeby:4===e,isGor:5===e};return Object.assign(Object.assign({},t),{isETH:t.isMainnet||t.isRinkeby||t.isGor})};var Ce;!function(e){e[e.MAINNET=1]="MAINNET",e[e.RINKEBY=4]="RINKEBY",e[e.GOERLI=5]="GOERLI",e[e.BSC=56]="BSC",e[e.HECO=128]="HECO",e[e.POLYGON=137]="POLYGON",e[e.ARBITRUM_ONE=42161]="ARBITRUM_ONE",e[e.ARBITRUM_RINKEBY=421611]="ARBITRUM_RINKEBY",e[e.AURORA=1313161554]="AURORA",e[e.MOONRIVER=1285]="MOONRIVER",e[e.OKCHAIN=66]="OKCHAIN",e[e.OPTIMISM=10]="OPTIMISM",e[e.BOBA=288]="BOBA",e[e.AVALANCHE=43114]="AVALANCHE",e[e.CRONOS=25]="CRONOS"}(Ce||(Ce={}));const Ae={[Ce.MAINNET]:["https://rpc.ankr.com/eth","https://eth-mainnet.public.blastapi.io","https://eth-rpc.gateway.pokt.network","https://main-rpc.linkpool.io"],[Ce.RINKEBY]:["https://rinkeby-light.eth.linkpool.io/"],[Ce.GOERLI]:["https://goerli.optimism.io/"],[Ce.BSC]:["https://bsc-dataseed1.binance.org","https://bsc-dataseed2.binance.org","https://bsc-dataseed3.binance.org","https://bsc-dataseed4.binance.org","https://bsc-dataseed1.defibit.io","https://bsc-dataseed2.defibit.io","https://bsc-dataseed3.defibit.io","https://bsc-dataseed4.defibit.io","https://bsc-dataseed1.ninicoin.io","https://bsc-dataseed2.ninicoin.io","https://bsc-dataseed3.ninicoin.io","https://bsc-dataseed4.ninicoin.io","https://bsc-dataseed.binance.org","https://rpc.ankr.com/bsc","https://bscrpc.com","https://bsc.mytokenpocket.vip","https://binance.nodereal.io","https://rpc-bsc.bnb48.club"],[Ce.HECO]:["https://http-mainnet.hecochain.com","https://pub001.hg.network/rpc"],[Ce.POLYGON]:["https://polygon-rpc.com","https://rpc-mainnet.matic.network","https://matic-mainnet.chainstacklabs.com","https://rpc-mainnet.maticvigil.com","https://rpc-mainnet.matic.quiknode.pro","https://matic-mainnet-full-rpc.bwarelabs.com","https://matic-mainnet-archive-rpc.bwarelabs.com","https://poly-rpc.gateway.pokt.network","https://rpc.ankr.com/polygon","https://polygon-mainnet.public.blastapi.io"],[Ce.ARBITRUM_ONE]:["https://arb1.arbitrum.io/rpc","https://rpc.ankr.com/arbitrum"],[Ce.ARBITRUM_RINKEBY]:["https://rinkeby.arbitrum.io/rpc"],[Ce.AURORA]:["https://mainnet.aurora.dev/"],[Ce.MOONRIVER]:["https://rpc.api.moonriver.moonbeam.network","https://moonriver.api.onfinality.io/rpc?apikey=673e1fae-c9c9-4c7f-a3d5-2121e8274366","https://moonriver.api.onfinality.io/public","https://moonriver.public.blastapi.io"],[Ce.OKCHAIN]:["https://exchainrpc.okex.org","https://okc-mainnet.gateway.pokt.network/v1/lb/6275309bea1b320039c893ff"],[Ce.OPTIMISM]:["https://mainnet.optimism.io","https://optimism-mainnet.public.blastapi.io"],[Ce.BOBA]:["https://mainnet.boba.network","https://boba-mainnet.gateway.pokt.network/v1/lb/623ad21b20354900396fed7f","https://lightning-replica.boba.network"],[Ce.AVALANCHE]:["https://api.avax.network/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://ava-mainnet.public.blastapi.io/ext/bc/C/rpc"],[Ce.CRONOS]:["https://evm.cronos.org","https://cronos-rpc.heavenswail.one","https://evm-cronos.crypto.org","https://cronosrpc-1.xstaking.sg","https://cronos-rpc.elk.finance"]},Oe={symbol:"ETH",address:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",name:"Ether",decimals:18,showDecimals:4,wrappedTokenSymbol:"WETH"},ke={[Ce.MAINNET]:Object.assign(Object.assign({},Oe),{wrappedTokenAddress:"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}),[Ce.RINKEBY]:Object.assign(Object.assign({},Oe),{wrappedTokenAddress:"0xB26c0d8Be2960c70641A95A9195BE1f59Ac83aC0"}),[Ce.GOERLI]:Object.assign(Object.assign({},Oe),{wrappedTokenAddress:"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6"}),[Ce.OPTIMISM]:Object.assign(Object.assign({},Oe),{wrappedTokenAddress:"0x4200000000000000000000000000000000000006"}),[Ce.CRONOS]:Object.assign(Object.assign({},Oe),{symbol:"CRO",name:"Cronos",wrappedTokenSymbol:"WCRO",wrappedTokenAddress:"0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23"}),[Ce.BOBA]:Object.assign(Object.assign({},Oe),{wrappedTokenAddress:"0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000"}),[Ce.BSC]:Object.assign(Object.assign({},Oe),{symbol:"BNB",name:"BNB",wrappedTokenSymbol:"WBNB",wrappedTokenAddress:"0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"}),[Ce.OKCHAIN]:Object.assign(Object.assign({},Oe),{symbol:"OKT",name:"OKT",wrappedTokenSymbol:"WOKT",wrappedTokenAddress:"0x8F8526dbfd6E38E3D8307702cA8469Bae6C56C15"}),[Ce.HECO]:Object.assign(Object.assign({},Oe),{symbol:"HT",name:"HT",showDecimals:6,wrappedTokenSymbol:"WHT",wrappedTokenAddress:"0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f"}),[Ce.POLYGON]:Object.assign(Object.assign({},Oe),{symbol:"MATIC",name:"MATIC",showDecimals:6,wrappedTokenSymbol:"WMATIC",wrappedTokenAddress:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"}),[Ce.MOONRIVER]:Object.assign(Object.assign({},Oe),{symbol:"MOVR",name:"MOVR",showDecimals:6,wrappedTokenSymbol:"WMOVR",wrappedTokenAddress:"0x98878b06940ae243284ca214f92bb71a2b032b8a"}),[Ce.ARBITRUM_ONE]:Object.assign(Object.assign({},Oe),{name:"Ethereum",showDecimals:6,wrappedTokenAddress:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"}),[Ce.ARBITRUM_RINKEBY]:Object.assign(Object.assign({},Oe),{name:"Ether",showDecimals:6,wrappedTokenAddress:"0xEBbc3452Cc911591e4F18f3b36727Df45d6bd1f9"}),[Ce.AURORA]:Object.assign(Object.assign({},Oe),{name:"Ethereum",showDecimals:6,wrappedTokenAddress:"0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB"}),[Ce.AVALANCHE]:Object.assign(Object.assign({},Oe),{symbol:"AVAX",name:"Avalanche",showDecimals:6,wrappedTokenSymbol:"WAVAX",wrappedTokenAddress:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7"})},Te={[Ce.MAINNET]:"ethereum",[Ce.RINKEBY]:"rinkeby",[Ce.GOERLI]:"goerli",[Ce.OPTIMISM]:"optimism",[Ce.CRONOS]:"cronos",[Ce.BOBA]:"boba",[Ce.BSC]:"bsc",[Ce.OKCHAIN]:"okex-chain",[Ce.HECO]:"heco",[Ce.POLYGON]:"polygon",[Ce.MOONRIVER]:"moonriver",[Ce.ARBITRUM_ONE]:"arbitrum",[Ce.ARBITRUM_RINKEBY]:"arb-rinkeby",[Ce.AURORA]:"aurora",[Ce.AVALANCHE]:"avalanche"},Ie={[Ce.MAINNET]:"etherscan.io",[Ce.RINKEBY]:"rinkeby.etherscan.io",[Ce.GOERLI]:"goerli.etherscan.io",[Ce.OPTIMISM]:"optimistic.etherscan.io",[Ce.CRONOS]:"cronoscan.com",[Ce.BOBA]:"blockexplorer.boba.network",[Ce.BSC]:"bscscan.com",[Ce.OKCHAIN]:"www.oklink.com/okexchain",[Ce.HECO]:"hecoinfo.com",[Ce.POLYGON]:"polygonscan.com",[Ce.MOONRIVER]:"moonriver.moonscan.io",[Ce.ARBITRUM_ONE]:"arbiscan.io",[Ce.ARBITRUM_RINKEBY]:"testnet.arbiscan.io",[Ce.AURORA]:"aurorascan.dev",[Ce.AVALANCHE]:"snowtrace.io"},Le=({tokenAmount:e,tokenAddress:t,chainId:o})=>{let i=new n(0);const r=ke[o];return t.toLowerCase()===r.address.toLowerCase()&&(i=ve(e,18)),`0x${i.toString(16)}`};function Re(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function Se(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{l(o.next(e))}catch(e){r(e)}}function s(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}const De={colorMode:"dark",slippage:3..toString(),ddl:20};var Ne=(e=De,t)=>{switch(t.type){case"SET_COLOR_MODE":return Object.assign(Object.assign({},e),{colorMode:t.payload});case"SET_SLIPPAGE":return Object.assign(Object.assign({},e),{slippage:t.payload});case"SET_TRANSACTION_DDL":return Object.assign(Object.assign({},e),{ddl:t.payload});default:return e}};const _e={chainId:Ce.MAINNET,latestBlockNumber:0};const Be={tokenList:[],popularTokenList:[],ethBalance:void 0,accountBalances:{},balanceLoadings:{},slippageWithTokens:[]};const Pe={height:void 0,width:void 0,apikey:"",feeRate:0,rebateTo:""};const Fe={settings:De,wallet:_e,globals:Pe,token:Be},je=G({reducer:Y({settings:Ne,wallet:(e=_e,t)=>{switch(t.type){case"SET_CHAIN_ID":return Object.assign(Object.assign({},e),{chainId:t.payload});case"SET_BLOCK_NUMBER":return Object.assign(Object.assign({},e),{latestBlockNumber:t.payload});default:return e}},token:(e=Be,t)=>{switch(t.type){case"SET_TOKEN_LIST":return Object.assign(Object.assign({},e),{tokenList:t.payload});case"SET_POPULAR_TOKEN_LIST":return Object.assign(Object.assign({},e),{popularTokenList:t.payload});case"SET_SLIPPAGE_WITH_TOKENS":return Object.assign(Object.assign({},e),{slippageWithTokens:t.payload});case"SET_ETH_BALANCE":return Object.assign(Object.assign({},e),{ethBalance:t.payload});case"SET_DEFAULT_FROM_TOKEN":return Object.assign(Object.assign({},e),{defaultFromToken:t.payload});case"SET_DEFAULT_TO_TOKEN":return Object.assign(Object.assign({},e),{defaultToToken:t.payload});case"SET_ACCOUNT_BALANCES":return Object.assign(Object.assign({},e),{accountBalances:Object.assign(Object.assign({},e.accountBalances),t.payload)});case"SET_ACCOUNT_ALLOWANCES":const n=e.accountBalances;return Object.keys(n).map((e=>{n[e].tokenAllowances=t.payload})),Object.assign(Object.assign({},e),{accountBalances:n});case"SET_BALANCE_LOADINGS":return Object.assign(Object.assign({},e),{balanceLoadings:Object.assign(Object.assign({},e.balanceLoadings),t.payload)});default:return e}},globals:(e=Pe,t)=>"SET_GLOBAL_PROPS"===t.type?Object.assign(Object.assign({},e),t.payload):e}),middleware:e=>e({serializableCheck:{ignoredActions:["SET_ACCOUNT_BALANCES","SET_ETH_BALANCE"],ignoredPaths:["token.accountBalances","token.ethBalance"]}}),preloadedState:Fe}),Me=e=>(null!=e?e:je.getState()).wallet.chainId,Ue=e=>(null!=e?e:je.getState()).wallet.latestBlockNumber,He=e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_ACCOUNT_BALANCES",payload:e})})),We=e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_BALANCE_LOADINGS",payload:e})}));var $e=[{constant:!0,inputs:[],name:"getCurrentBlockTimestamp",outputs:[{name:"timestamp",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{components:[{name:"target",type:"address"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate",outputs:[{name:"blockNumber",type:"uint256"},{name:"returnData",type:"bytes[]"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"getLastBlockHash",outputs:[{name:"blockHash",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"addr",type:"address"}],name:"getEthBalance",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"getCurrentBlockDifficulty",outputs:[{name:"difficulty",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"getCurrentBlockGasLimit",outputs:[{name:"gaslimit",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"getCurrentBlockCoinbase",outputs:[{name:"coinbase",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"blockNumber",type:"uint256"}],name:"getBlockHash",outputs:[{name:"blockHash",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"}],Ve={[Ce.MAINNET]:{MULTI_CALL:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",DODO_APPROVE:"0x14F7B8Fb0c1447DdE7bcf92a8d9BB058c8A5FE64",ERC20_HELPER:"0xD9ef2d1583e8Aa196123e773BE38B539a4d149df"},[Ce.RINKEBY]:{MULTI_CALL:"0xb7E1C577f95959a3eD11f9281702850328b4e0e4",DODO_APPROVE:"0xcC8d87A7C747eeE4242045C47Ef25e0A81D56ae3",ERC20_HELPER:"0x6A42091d713A67E25a1D11aeE14E7AEB96E0331f"},[Ce.GOERLI]:{MULTI_CALL:"0x696E25A5e2AEd1C55E6d6Cfa0532Bbda9020165d",DODO_APPROVE:"0xC9143e54021f4a6d33b9b89DBB9F458AaEdd56FB",ERC20_HELPER:"0x24549FC74B3076A962624A26370ed556c467F74C"},[Ce.BSC]:{MULTI_CALL:"0x1Ee38d535d541c55C9dae27B12edf090C608E6Fb",DODO_APPROVE:"0x7F91869b17968299Ac0e008cca8AD0E6C1b6Ed05",ERC20_HELPER:"0x566651Ad34f6306872FaC5fB95bbF4C9beE8D8F2"},[Ce.HECO]:{MULTI_CALL:"0x76a328B3440B9276a31523e731B34082df7a6f1A",DODO_APPROVE:"0x68b6c06Ac8Aa359868393724d25D871921E97293",ERC20_HELPER:"0x270C2abC692Dd476B860CCbDfD6D8146BF61f8D8"},[Ce.POLYGON]:{MULTI_CALL:"0xc9eD9B18e447e600238fe50e944B9062B664DEa4",DODO_APPROVE:"0x292E6b2e054e1157df71C1C9510265CA8C0c7672",ERC20_HELPER:"0xfd24312Ec7871A6D1a31e454D5AbB16c6c25a9b3"},[Ce.ARBITRUM_ONE]:{MULTI_CALL:"0xF718F2bd590E5621e53f7b89398e52f7Acced8ca",DODO_APPROVE:"0xA867241cDC8d3b0C07C85cC06F25a0cD3b5474d8",ERC20_HELPER:"0x7C062B9C584fA6eC2504270790D38240A2c5fE72"},[Ce.ARBITRUM_RINKEBY]:{MULTI_CALL:"0x696E25A5e2AEd1C55E6d6Cfa0532Bbda9020165d",DODO_APPROVE:"0x5BaF16d57620Cb361F622232F3cb4090e35F3da2",ERC20_HELPER:"0x5B2fd46E6E3Ff1E479d651ec0b210882Aa9871dF"},[Ce.AURORA]:{MULTI_CALL:"0x989DcAA95801C527C5B73AA65d3962dF9aCe1b0C",DODO_APPROVE:"0x335aC99bb3E51BDbF22025f092Ebc1Cf2c5cC619",ERC20_HELPER:"0xE8C9A78725D0451FA19878D5f8A3dC0D55FECF25"},[Ce.MOONRIVER]:{MULTI_CALL:"0x2ff2CeE6E9359F9eA1cF2f51d18bF9F2045447E4",DODO_APPROVE:"0xE8C9A78725D0451FA19878D5f8A3dC0D55FECF25",ERC20_HELPER:"0x6373ceB657C83C91088d328622573FB766064Ac4"},[Ce.OKCHAIN]:{MULTI_CALL:"0x5e84190a270333aCe5B9202a3F4ceBf11b81bB01",DODO_APPROVE:"0x7737fd30535c69545deeEa54AB8Dd590ccaEBD3c",ERC20_HELPER:"0x4775b1858f1e417C9609D455C3Ad8751ec01daC4"},[Ce.OPTIMISM]:{MULTI_CALL:"0xb98Ac2fEFc8b73aeAE33D02BB00c26E12afCa9Df",DODO_APPROVE:"0xa492d6eABcdc3E204676f15B950bBdD448080364",ERC20_HELPER:"0x42E456ea0dd7538ea103fBb1d0388D14C97bB5b2"},[Ce.BOBA]:{MULTI_CALL:"0xD56281EF996B6B29874C77D2e1464216E8043127",DODO_APPROVE:"0x8F8Dd7DB1bDA5eD3da8C9daf3bfa471c12d58486",ERC20_HELPER:"0x9FCFD9ff955D36856F8EE480471B05488C0eB5cA"},[Ce.AVALANCHE]:{MULTI_CALL:"0x97f0153E7F5749640aDF3Ff9CFC518b79D6Fe53b",DODO_APPROVE:"0xCFea63e3DE31De53D68780Dd65675F169439e470",ERC20_HELPER:"0xC3528D128CC227fd60793007b5e3FdF7c2945282"},[Ce.CRONOS]:{MULTI_CALL:"0x4f4408D78F9E9e242c17C635FbD0f1952951c917",DODO_APPROVE:"0x9B736bB8f336f61E16454DCA4dE130703D151042",ERC20_HELPER:"0xbd2F5c60cf7d60daD2106ceD4D21b90722761f14"}};function ze(e,t,...n){return Se(this,void 0,void 0,(function*(){const o=[];for(const e of n)for(const t of e)t.callData&&o.push(t.callData);const i=yield function(e,t,n){return Se(this,void 0,void 0,(function*(){const o=yield Ke(e,t,n),i=new Map;for(const{req:e,resp:t}of o)i.set(e,t);return e.map((e=>({req:e,resp:i.get(e)})))}))}(o,e,t),r=new Map;for(const{req:e,resp:t}of i)r.set(e,null==t?void 0:t.result);return n.map((e=>e.filter((e=>!e.callData||r.get(e.callData))).map(((e,t)=>e.processor(e.callData?r.get(e.callData):null,t)))))}))}function Ke(e,t,n){return Se(this,void 0,void 0,(function*(){let o=[e];e.length>800&&(o=i(e,800));let r=[];const a=o.map((e=>Se(this,void 0,void 0,(function*(){const o=e.map((e=>[e.to,e.data])),i={data:t.interface.encodeFunctionData("aggregate",[o]),to:n};let a;try{a=yield t.provider.call(i)}catch(o){const i=e.length;if(i>20){const o=Math.floor(i/2),[a,s]=yield Promise.all([Ke(e.slice(0,o),t,n),Ke(e.slice(o,i),t,n)]);r=[...r,...a,...s]}else{const e="[sendCallReqs] error";console.error(e,o)}}if(void 0===a)throw new Error("Unexpected batch result");const[s,l]=Z.decode(["uint256","bytes[]"],a);if(e.length!==l.length)throw new Error("Unexpected length mismatch");return l.map(((t,n)=>({resp:{result:t},req:e[n]})))}))));return(yield Promise.allSettled(a)).filter((e=>"fulfilled"===e.status)).forEach((({value:e})=>{r=[...r,...e]})),r}))}function Ge(e,t,n,o){if(!function(e){try{return y(e)}catch(e){return!1}}(e)||e===X)throw Error(`Invalid 'address' parameter '${e}'.`);return new q(e,t,function(e,t){return t?function(e,t){return e.getSigner(t).connectUnchecked()}(e,t):e}(n,o))}function Ye(){const{provider:e,account:t,chainId:n}=V(),[o,i]=v(!1),r=E((()=>Ve[n]),[n]),a=w(((n,o)=>{if(e)return Ge(n,o,e,t)}),[e,t]),s=w((e=>{if(!r)return;const{MULTI_CALL:t}=r,n=a(t,$e);return(()=>Se(this,void 0,void 0,(function*(){if(n){i(!0);try{const[o]=yield ze(n,t,e);return o}catch(e){console.error("Contract: useMultiContract is error",e)}i(!1)}})))()}),[r,a]);return{getContract:a,contractConfig:r,call:s,loading:o}}var qe=[{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"user",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"isERC20",outputs:[{internalType:"bool",name:"isOk",type:"bool"},{internalType:"string",name:"symbol",type:"string"},{internalType:"string",name:"name",type:"string"},{internalType:"uint256",name:"decimals",type:"uint256"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"allownance",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"user",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"judgeERC20",outputs:[{internalType:"string",name:"symbol",type:"string"},{internalType:"string",name:"name",type:"string"},{internalType:"uint256",name:"decimals",type:"uint256"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"allownance",type:"uint256"}],stateMutability:"view",type:"function"}];function Xe(){const{provider:e,account:t}=V(),o=T(),i=I(Ue);C((()=>{(()=>{Se(this,void 0,void 0,(function*(){if(!e||!t)return;const i=yield e.getBalance(t);o((e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_ETH_BALANCE",payload:e})})))(new n(i.toString()).div(1e18)))}))})()}),[e,t,o,i])}function Ze(){const{provider:e,chainId:t}=V(),n=T();C((()=>{const o=e=>{n((e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_BLOCK_NUMBER",payload:e})})))(e))};return(()=>{Se(this,void 0,void 0,(function*(){if(!e||!t)return;const n=yield e.getBlockNumber();o(n),e.on("block",o)}))})(),()=>{null==e||e.off("block",o)}}),[e,n,t])}function Qe(e){return Number.parseInt(e,16)}class Je extends oe{constructor(e,t){super(e),this.customProvider=t,t.on("connect",(({chainId:e})=>{this.actions.update({chainId:Qe(e)})})).on("disconnect",(e=>{var t;null===(t=this.onError)||void 0===t||t.call(this,e),this.actions.resetState()})).on("chainChanged",(e=>{this.actions.update({chainId:Qe(e)})})).on("accountsChanged",(e=>{this.actions.update({accounts:e})}))}activate(){return Se(this,void 0,void 0,(function*(){this.actions.startActivation();const e=this.customProvider;try{const[{chainId:t},n]=yield Promise.all([e.getNetwork(),e.listAccounts()]);this.actions.update({chainId:t,accounts:n})}catch(e){throw this.actions.resetState(),e}}))}}function et([e,t]){return[e,t]}var tt;function nt(){return nt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},nt.apply(this,arguments)}var ot,it;function rt(){return rt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},rt.apply(this,arguments)}var at;!function(e){e.INTEGRATOR="integrator",e.METAMASK="metamask",e.WALLET_CONNECT="walletConnect"}(at||(at={}));const st={[at.METAMASK]:{name:"MetaMask",type:at.METAMASK,icon:function(e){return x.createElement("svg",nt({height:355,viewBox:"0 0 397 355",width:397,xmlns:"http://www.w3.org/2000/svg"},e),tt||(tt=x.createElement("g",{fill:"none",fillRule:"evenodd",transform:"translate(-1 -1)"},x.createElement("path",{d:"m114.622644 327.195472 52.004717 13.810198v-18.05949l4.245283-4.249292h29.716982v21.246459 14.872523h-31.839624l-39.268868-16.997169z",fill:"#cdbdb2"}),x.createElement("path",{d:"m199.528305 327.195472 50.943397 13.810198v-18.05949l4.245283-4.249292h29.716981v21.246459 14.872523h-31.839623l-39.268868-16.997169z",fill:"#cdbdb2",transform:"matrix(-1 0 0 1 483.96227 0)"}),x.createElement("path",{d:"m170.872644 287.889523-4.245283 35.056657 5.306604-4.249292h55.18868l6.367925 4.249292-4.245284-35.056657-8.490565-5.311615-42.452832 1.062323z",fill:"#393939"}),x.createElement("path",{d:"m142.216984 50.9915022 25.471698 59.4900858 11.674528 173.158643h41.391511l12.735849-173.158643 23.349056-59.4900858z",fill:"#f89c35"}),x.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),x.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),x.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),x.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),x.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 56.25-39.305949z",fill:"#eb8f35"}),x.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),x.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),x.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),x.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),x.createElement("path",{d:"m114.622644 327.195472 56.25-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3"}),x.createElement("path",{d:"m229.245286 327.195472 55.18868-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3",transform:"matrix(-1 0 0 1 513.679252 0)"}),x.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),x.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),x.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"}),x.createElement("g",{transform:"matrix(-1 0 0 1 399.056611 0)"},x.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),x.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),x.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),x.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),x.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 55.18868-38.243626z",fill:"#eb8f35"}),x.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),x.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),x.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),x.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),x.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),x.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),x.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"})))))},link:"https://metamask.io"},[at.WALLET_CONNECT]:{name:"WalletConnect",type:at.WALLET_CONNECT,icon:function(e){return x.createElement("svg",rt({height:512,viewBox:"0 0 512 512",width:512,xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),ot||(ot=x.createElement("radialGradient",{id:"a",cx:"0%",cy:"50%",r:"100%"},x.createElement("stop",{offset:0,stopColor:"#5d9df6"}),x.createElement("stop",{offset:1,stopColor:"#006fff"}))),it||(it=x.createElement("g",{fill:"none",fillRule:"evenodd"},x.createElement("path",{d:"m256 0c141.384896 0 256 114.615104 256 256s-114.615104 256-256 256-256-114.615104-256-256 114.615104-256 256-256z",fill:"url(#a)"}),x.createElement("path",{d:"m64.6917558 37.7088298c51.5328072-50.2784397 135.0839942-50.2784397 186.6167992 0l6.202057 6.0510906c2.57664 2.5139218 2.57664 6.5897948 0 9.1037177l-21.215998 20.6995759c-1.288321 1.2569619-3.3771 1.2569619-4.665421 0l-8.534766-8.3270205c-35.950573-35.0754962-94.237969-35.0754962-130.188544 0l-9.1400282 8.9175519c-1.2883217 1.2569609-3.3771016 1.2569609-4.6654208 0l-21.2159973-20.6995759c-2.5766403-2.5139229-2.5766403-6.5897958 0-9.1037177zm230.4934852 42.8089117 18.882279 18.4227262c2.576627 2.5139103 2.576642 6.5897593.000032 9.1036863l-85.141498 83.070358c-2.576623 2.513941-6.754182 2.513969-9.33084.000066-.00001-.00001-.000023-.000023-.000033-.000034l-60.428256-58.957451c-.64416-.628481-1.68855-.628481-2.33271 0-.000004.000004-.000008.000007-.000012.000011l-60.4269683 58.957408c-2.5766141 2.513947-6.7541746 2.51399-9.3308408.000092-.0000151-.000014-.0000309-.000029-.0000467-.000046l-85.14386774-83.071463c-2.57663928-2.513921-2.57663928-6.589795 0-9.1037163l18.88231264-18.4226955c2.5766393-2.5139222 6.7541993-2.5139222 9.3308397 0l60.4291347 58.9582758c.6441608.62848 1.6885495.62848 2.3327103 0 .0000095-.000009.0000182-.000018.0000277-.000025l60.4261065-58.9582508c2.576581-2.51398 6.754142-2.5140743 9.33084-.0002103.000037.0000354.000072.0000709.000107.0001063l60.429056 58.9583548c.644159.628479 1.688549.628479 2.332709 0l60.428079-58.9571925c2.57664-2.5139231 6.754199-2.5139231 9.330839 0z",fill:"#fff",fillRule:"nonzero",transform:"translate(98 160)"}))))}}},lt={};function ct({provider:e,jsonRpcUrlMap:t,defaultChainId:n}){const o=console.error,i=E((()=>function(e,t){if(t){if(ne.isProvider(t))return et(z((e=>new Je(e,t))));if(ne.isProvider(t.provider))throw new Error("Eip1193Bridge is experimental: pass your ethers Provider directly");return et(z((n=>new J({actions:n,provider:t,onError:e}))))}}(o,e)),[o,e]),r=E((()=>function(e){return et(z((t=>new te({actions:t,onError:e}))))}(o)),[o]),a=E((()=>t?Object.assign(Object.assign({},Ae),t):Ae),[t]),s=E((()=>function(e,t,n,o){return et(z((i=>new ee({actions:i,options:{rpc:t,qrcode:e},onError:o,defaultChainId:n}))))}(!0,a,n,o)),[a,n,o]);return i&&(lt[at.INTEGRATOR]=i),lt[at.METAMASK]=r,lt[at.WALLET_CONNECT]=s,Object.values(lt)}function dt(){const{chainId:e}=V(),t=I(Me);return E((()=>e||t||1),[e,t])}function ut({tokenList:e,popularTokenList:t}){const o=T(),[i,r]=v([]),{account:a}=V(),s=dt(),l=I(Ue),c=E((()=>(null==t?void 0:t.filter((e=>e.chainId===s)))||[]),[t,s]);!function({tokenList:e,addresses:t,blockNumber:o}){const{account:i}=V(),r=T(),a=E((()=>[...(null==e?void 0:e.map((e=>e.address)))||[],...t||[]].map((e=>e.toLocaleLowerCase()))),[e,t]),{getContract:s,contractConfig:l,call:c}=Ye(),[d,u]=v(),p=E((()=>{if(!i||!a.length||!l)return;const{DODO_APPROVE:e,ERC20_HELPER:t}=l,o=s(t,qe);if(!o)return;let c={};const d=a.map((r=>(c[r]=!0,{callData:{data:o.interface.encodeFunctionData("isERC20",[r,i,e]),to:t},processor:e=>{const t=new Q(qe).decodeFunctionResult("isERC20",e),{balance:o,isOk:i}=t,a=parseInt(t.decimals),s=new n(10).pow(a),l=new n(t.allownance.toString()).div(s);return i?{address:r,decimals:a,symbol:t.symbol,name:t.name,balance:new n(o.toString()).div(s),allowance:l}:{address:r,balance:new n(0),allowance:new n(0)}}})));return r(We(c)),d}),[i,s,a]);C((()=>{(()=>{Se(this,void 0,void 0,(function*(){if(!p)return;const e=yield c(p),t={};e&&(e.forEach((e=>{t[e.address.toLocaleLowerCase()]={tokenBalances:e.balance,tokenAllowances:e.allowance}})),r(He(t))),u(e);let n={};a.forEach((e=>{n[e]=!1})),r(We(n))}))})()}),[p,o])}({addresses:E((()=>{const e=i.map((({address:e})=>e));return null==t||t.forEach((({address:t})=>{e.includes(t)||e.push(t)})),e}),[i,t]),blockNumber:l}),C((()=>{(()=>{Se(this,void 0,void 0,(function*(){let t=[];if(e)t=e;else{t=(yield import("./tokenList-4ef211de.js")).default}const n=s,i=t.filter((e=>e.chainId===n));r(i),o((e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_TOKEN_LIST",payload:e})})))(i))}))})()}),[e,o,s]),C((()=>{o(He({}))}),[a,s]),C((()=>{o((e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_POPULAR_TOKEN_LIST",payload:e})})))(c))}),[c,o])}const pt=e=>(null!=e?e:je.getState()).token.tokenList,mt=e=>(null!=e?e:je.getState()).token.accountBalances,ht=e=>(null!=e?e:je.getState()).token.ethBalance||new n(NaN),ft=e=>(null!=e?e:je.getState()).token.defaultFromToken,gt=e=>(null!=e?e:je.getState()).token.defaultToToken,bt=e=>(null!=e?e:je.getState()).token.balanceLoadings;function yt(){const{account:e,chainId:t}=V(),n=I(mt),o=I(ht),i=E((()=>ke[t||1]),[t]),r=w((t=>{var r;if(!e)return null;if(t.symbol===i.symbol&&Ee(t.address,i.address))return!o||(null==o?void 0:o.isNaN())?null:o;const a=null===(r=n[t.address.toLocaleLowerCase()])||void 0===r?void 0:r.tokenBalances;return!a||(null==a?void 0:a.isNaN())?null:a}),[n,o,e]);return r}var xt;function vt(e,t,n,o=0){if(n&&(e=e.toLocaleLowerCase(),t=t.toLocaleLowerCase()),e===t)return xt.fully+o;const i=e.indexOf(t);return 0===i?xt.prefix+o:i>0?xt.other+o:xt.none}!function(e){e[e.fully=1]="fully",e[e.prefix=2]="prefix",e[e.other=3]="other",e[e.none=0]="none"}(xt||(xt={}));function Et({value:e,onChange:t,occupiedAddrs:o,hiddenAddrs:i,showAddrs:r}){const[a,s]=v(""),l=I(pt),c=dt(),d=yt(),u=E((()=>new Set(i?i.map((e=>e.toLowerCase())):void 0)),[i]),p=E((()=>r?new Set(r.map((e=>e.toLowerCase()))):void 0),[r]),m=w((e=>e.filter((e=>{if(e.chainId!==c)return!1;let t=!0;return t=p?p.has(e.address.toLowerCase()):!u.has(e.address.toLowerCase()),t}))),[p,c,u]),h=w((t=>{if(null===t)return null;const i=[];a?t.forEach((e=>{const t=((e,t,{matchAddress:n}={})=>{if(!t)return 0;const o=t.toLocaleLowerCase();let i=0;n&&e.address.toLocaleLowerCase()===o&&(i=1),i||(i=vt(e.symbol.toLocaleLowerCase(),o,!1,1));if(i)e.name.toLocaleLowerCase()===o&&(i=xt.fully+1);else{let t=vt(e.name.toLocaleLowerCase(),o,!1,10);t=t===xt.fully+10?xt.fully+1:t,i=t}return i})(e,a,{matchAddress:!0});t&&i.push({sort:t,token:e})})):t.forEach((e=>{i.push({sort:0,token:e})}));const r=[];return i.sort(((t,i)=>{const r=t.token,a=i.token;if(e){if(r.address===e.address)return-1;if(a.address===e.address)return 1}if(null==o?void 0:o.includes(r.address))return-1;if(null==o?void 0:o.includes(a.address))return 1;const s=d&&d(r)||new n(0),l=d&&d(a)||new n(0);return s.eq(l)?t.sort!==i.sort?t.sort>i.sort?1:-1:r.symbol.localeCompare(a.symbol):s.gt(l)?-1:1})).some((e=>!!(a&&r.length>21)||(r.push(e.token),!1))),r}),[a,d,o,e]),f=w((e=>{const n=e.address.toLowerCase();t(e,!!(null==o?void 0:o.some((e=>e.toLowerCase()===n))))}),[t,o]),g=E((()=>{const e=m(l);return h(e)||[]}),[l,m,h]);return{filter:a,setFilter:s,showTokenList:g,onSelectToken:f}}function wt({width:e=24,height:t=24,marginRight:n=8,url:o,zIndex:i,cross:r,address:s,token:l,sx:c}){const[d,u]=v(!1),[p,m]=v(""),[h,f]=v(""),[g,b]=v(!1),y=w((()=>u(!0)),[]);let x=function(e){const t=I(pt),{chainId:n}=V();return E((()=>{if(!e)return;let o=t.find((({address:t,chainId:o})=>o===n&&t===e));return o||(o=t.find((({address:t})=>t===e))),o}),[e,t,n])}(s);l&&(x=l);const A=s||(null==x?void 0:x.address),O=null==x?void 0:x.symbol,k=null==O?void 0:O.charAt(0).toUpperCase(),T=E((()=>{const e=null==x?void 0:x.logoURI;return o||e||""}),[o,x]);return C((()=>{b(!1)}),[A,T]),C((()=>{r&&(T?function(e,t){const n=new XMLHttpRequest;let o;n.onload=function(){const e=new FileReader;e.onloadend=function(){t(e.result)},e.readAsDataURL(n.response)},n.onerror=function(){t()};try{o=new URL(e)}catch(e){}finally{n.open("GET",o||e),n.responseType="blob",n.send()}}(T,(e=>{m(e)})):m(""))}),[T,r]),C((()=>{try{let t=A;if(t&&t.length<15&&(t=t.padEnd(15,"0")),t){const n=new $(t,{size:e,format:"svg",margin:.2,background:[255,234,4,255]}).toString();f(`data:image/svg+xml;base64,${n}`)}}catch(e){console.error("generate Identicon error: ",e)}}),[A,e]),ie(a,{sx:Object.assign({position:"relative",display:"flex",alignItems:"center",justifyContent:"center",minWidth:e,width:e,height:t,marginRight:n,zIndex:i},c||{}),style:{width:e,height:t},children:[!d&&re(a,{sx:{typography:"ht",height:"100%",width:"100%",borderRadius:"50%",border:"transparent 2px solid",borderColor:"text.primary",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"center"},children:k}),re(a,{component:"img",src:!(r?p:T)||g?h:r?p:T,onLoad:y,onError:e=>{const t=e.target;A&&h&&b(!0),t.onerror=null},sx:{position:"absolute",top:"0",bottom:"0",left:"0",right:"0",borderRadius:"50%",overflow:"hidden",width:"100%",height:"100%"}})]})}function Ct({token:t,onClick:n}){var o,i;const r=s();return ie(a,{component:l,sx:{display:"flex",alignItems:"center",color:r.palette.text.primary,typography:"h5",fontWeight:600},onClick:e=>{n&&n(e)},"data-testid":"swap-select-token-btn",children:[(null==t?void 0:t.address)?ie(ae,{children:[re(wt,{address:null!==(o=null==t?void 0:t.address)&&void 0!==o?o:"",marginRight:6}),re(a,{children:null!==(i=null==t?void 0:t.symbol)&&void 0!==i?i:"-"})]}):re(e,{id:"SELECT TOKEN"}),re(a,{sx:{ml:7,width:12,transform:"rotateX(180deg)"},component:R})]})}function At({onClick:t,balance:n,decimals:o,address:i,showMaxBtn:r}){const{palette:c}=s();return ie(a,{sx:{display:"flex",typography:"body2",color:c.text.secondary},children:[re(e,{id:"Balance:"})," ",i?ge({input:n,decimals:Math.min(o||4,4)}):"-",r&&n&&n.gt(0)&&re(a,{component:l,sx:{ml:6,color:(null==n?void 0:n.gt(0))?c.primary.main:c.text.disabled,cursor:i&&t?"pointer":"unset"},onClick:()=>t&&t(n?n.toString():""),children:re(e,{id:"Max"})})]})}function Ot({readOnly:e,sx:t,value:n,decimals:o,onChange:i,suffix:r,withClear:d,placeholder:u}){const p=s(),m=E((()=>r||(d&&n&&i?re(a,{component:l,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},onClick:()=>{i&&i("")},children:re(a,{component:S,sx:{width:12,color:"text.primary"}})}):void 0)),[i,r,p.palette.text.primary,n,d]);return ie(a,{sx:Object.assign({mt:12,display:"flex",justifyContent:"space-between",alignItems:"center"},t),"data-testid":"number-input-wrapper",children:[re(c,{fullWidth:!0,value:n,readOnly:e,placeholder:u||"0.00",onChange:e=>{const t=e.target.value,n=0===t.length?"":xe(t,o);i&&i(n)},sx:{width:"inherit",border:"none","& .MuiInput-input":{fontSize:24,border:"none",outline:"none",height:24,padding:0,color:"text.primary","&::placeholder":{fontSize:24,color:"text.disabled"}}}}),!e&&n&&m]})}function kt({open:e,onClose:t,title:n,rightSlot:o,canBack:i=!0,children:r,height:s,testId:l}){return ie(a,{sx:{position:"absolute",top:e?0:"100%",transition:"top 300ms",zIndex:1,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",backgroundColor:"background.paper",borderRadius:16,height:s},"data-testid":l,"data-active":e?"1":"0",children:[n?ie(a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:20},children:[re(a,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:n}),o,!o&&i&&re(a,{component:S,sx:{color:"text.secondary",cursor:"pointer"},onClick:t})]}):"",r]})}const Tt=e=>(null!=e?e:je.getState()).globals;function It({token:e,disabled:t,onClick:n}){return ie(a,{sx:Object.assign({display:"inline-flex",alignItems:"center",p:8,border:"solid 1px",typography:"body2",borderRadius:8},t?{borderColor:"transparent",backgroundColor:"border.disabled",cursor:"auto"}:{borderColor:"border.main",cursor:"pointer","&:hover":{backgroundColor:"hover.default"}}),onClick:()=>{t||n()},children:[re(wt,{token:e}),e.symbol]})}function Lt({token:e,disabled:t,style:n,onClick:o}){const i=yt()(e),r=i?fe({input:i}):"";return ie(a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2",px:6,py:5,borderRadius:8,cursor:t?"auto":"pointer",opacity:t?.5:1,"&:hover":{backgroundColor:"hover.default"}},style:n,onClick:()=>{t||o()},"data-testid":"token-picker-item",children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(wt,{token:e}),ie(a,{children:[re(a,{sx:{fontWeight:600,textAlign:"left"},children:e.symbol}),re(a,{sx:{mt:4,textAlign:"left"},children:r})]})]}),re(a,{sx:{color:"text.secondary"},children:e.name})]})}function Rt({value:e,onChange:t,occupiedAddrs:n,hiddenAddrs:o,showAddrs:i,visible:r}){var s;const l=dt(),c=I((e=>((e,t)=>(null!=t?t:je.getState()).token.popularTokenList.filter((({chainId:t})=>e===t)))(l,e))),{showTokenList:u,filter:p,setFilter:m,onSelectToken:h}=Et({value:e,onChange:t,occupiedAddrs:n,hiddenAddrs:o,showAddrs:i}),f=A(null),g=A(null),[b,y]=v(0);C((()=>{r&&f.current&&y(f.current.offsetHeight-34)}),[f,r]);const x=w((({index:t,style:n})=>{const o=!!(null==c?void 0:c.length);if(0===t&&o)return re(a,{sx:{position:"relative",display:"flex",gap:8,flexWrap:"wrap",pb:32,"&::after":{content:'""',position:"absolute",bottom:16,left:0,right:0,height:"1px",backgroundColor:"border.main"}},ref:g,style:Object.assign(Object.assign({},n),{visibility:n.height?"visible":"hidden",height:n.height?n.height:"auto"}),children:c.map((t=>re(It,{token:t,disabled:(null==e?void 0:e.address)===t.address,onClick:()=>h(t)},t.address)))});const i=u[o?t-1:t];return re(Lt,{token:i,disabled:!!e&&e.address===i.address,style:n,onClick:()=>h(i)})}),[u,c,g,e]),E=w((e=>{var t;if(0===e&&(null==c?void 0:c.length)){const e=(null===(t=g.current)||void 0===t?void 0:t.offsetHeight)||0;return e<=52?0:e}return 52}),[g,c]);return ie(a,{sx:{display:"flex",flexDirection:"column",px:20,flex:1},children:[re(d,{fullWidth:!0,height:48,value:p,onChange:e=>m(e.target.value),clearValue:()=>m(""),placeholder:se._("Enter the token symbol or address")}),re(a,{sx:{mt:16,pb:16,flex:1,minHeight:64},ref:f,children:re(le,{height:b,itemCount:u.length+((null==c?void 0:c.length)?1:0),itemSize:E,width:"100%",className:"token-list",children:x},null===(s=g.current)||void 0===s?void 0:s.offsetHeight)})]})}function St({open:t,value:n,onClose:o,occupiedAddrs:i,onTokenChange:r}){const{height:a}=I(Tt);return re(kt,{height:a,open:t,onClose:o,title:re(e,{id:"Select a token"}),testId:"token-picker-wrapper",children:re(Rt,{value:n,visible:t,onChange:r,occupiedAddrs:i})})}function Dt({sx:e,amt:t,token:n,readOnly:o,showMaxBtn:i,onMaxClick:r,fiatPriceTxt:l,occupiedAddrs:c,onInputChange:d,onTokenChange:u}){const p=s(),m=yt(),[h,f]=v(!1),g=n?m(n):null;return ie(a,{sx:Object.assign({width:"100%",minHeight:133,padding:20,borderRadius:12,overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",backgroundColor:p.palette.background.input},e),children:[ie(a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[re(Ct,{token:n,onClick:()=>f(!0)}),re(At,{balance:g,onClick:r,showMaxBtn:i,address:null==n?void 0:n.address,decimals:null==n?void 0:n.decimals})]}),re(Ot,{value:t,onChange:d,readOnly:o,withClear:!0}),re(a,{sx:{mt:4,typography:"body2",color:p.palette.text.secondary},children:l}),re(St,{value:n,open:h,occupiedAddrs:c,onClose:()=>f(!1),onTokenChange:(e,t)=>{u(e,t),f(!1)}})]})}const Nt={"en-US":ce,"zh-CN":de,pseudo:ce};function _t({locale:e,children:n}){return C((()=>{(()=>{Se(this,void 0,void 0,(function*(){yield function(e="en-US"){return Se(this,void 0,void 0,(function*(){se.loadLocaleData(e,{plurals:()=>Nt[e]});try{const t=yield import(`./locales/${e}.js`);se.load(e,t.messages||t.default.messages)}catch(e){}se.activate(e)}))}(e)}))})()}),[e]),re(t,{i18n:se,children:n})}var Bt,Pt,Ft;!function(e){e[e.Running=0]="Running",e[e.Success=1]="Success",e[e.Failed=2]="Failed",e[e.Warning=3]="Warning"}(Bt||(Bt={})),function(e){e.Canceled="canceled",e.Failed="failed",e.Success="success",e.Submitted="submitted"}(Pt||(Pt={})),function(e){e[e.Failed=0]="Failed",e[e.Success=1]="Success"}(Ft||(Ft={}));var jt,Mt=[{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"guy",type:"address"},{name:"wad",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}];!function(e){e[e.Failed=0]="Failed",e[e.Success=1]="Success",e[e.Warning=2]="Warning"}(jt||(jt={}));const Ut=(e,t)=>Se(void 0,void 0,void 0,(function*(){const{value:n,from:o,to:i,data:r}=e,a={from:o,to:i,value:n,data:r};n&&!/^0x0*$/.test(n)||delete a.value;try{return(yield t.estimateGas(a)).add(5e4)}catch(e){t.call(a).then((e=>{if("test"!==process.env.NODE_ENV)throw new Error("Unexpected issue with estimating the gas. Please try again.")})).catch((e=>{if("test"!==process.env.NODE_ENV)throw e}))}return null})),Ht=(e,t)=>Se(void 0,void 0,void 0,(function*(){try{return yield t.getSigner().sendTransaction(e)}catch(e){throw 4001===(null==e?void 0:e.code)?new Error(se._("Transaction rejected.")):e}}));var Wt,$t;!function(e){e.Approval="APPROVAL",e.TX="TX",e.TypedSign="TypedSign"}(Wt||(Wt={})),function(e){e.Normal="Normal",e.Privacy="Privacy",e.LimitOrder="LimitOrder",e.RFQ="RFQ"}($t||($t={}));const Vt=new n(2).pow(256).minus(1);function zt({onTxFail:e,onTxSubmit:t,onTxSuccess:o}={}){const{account:i,provider:r}=V(),a=dt(),[s,l]=v(!1),[c,d]=v(new Map),[u,p]=v(null),[m,h]=v(""),[f,g]=v(null),[b,y]=v(!1),[x,C]=v(),A=w(((s,c,u,m=!1,f,b,x,v)=>Se(this,void 0,void 0,(function*(){if(h(""),p(""),!i||!r)throw new Error("Submission: Cannot execute step when the wallet is disconnected");let E,w,A;C((()=>x)),l(!1);try{if(l(!0),c.opcode===Wt.Approval)A=yield((e,t,o,i,r,a)=>Se(void 0,void 0,void 0,(function*(){const s=Ge(e,Mt,r,a).interface.encodeFunctionData("approve",[o,i.toFixed()]),l={from:t,to:e,data:s,value:`0x${new n("0").toString(16)}`,gasLimit:void 0},c=yield Ut(l,r);return c&&(l.gasLimit=c),yield Ht(l,r)})))(c.token.address,i,c.contract,c.amt||Vt,r,i),E=A.hash,h(E);else{if(c.opcode!==Wt.TX)throw new Error(`Op ${c.opcode} not implemented!`);if(""===c.to)throw new Error("Submission: malformed to");if(0===c.data.length)throw new Error("Submission: malformed data");if(0===c.data.indexOf("0x")&&c.data.length<=2)throw new Error("Submission: malformed data");if(w={value:c.value,data:c.data,to:c.to,gasLimit:c.gasLimit,from:i,chainId:a},!w.gasLimit)try{const e=yield Ut(w,r);e&&(w.gasLimit=e)}catch(e){console.debug(e)}if(A=yield Ht(w,r),E=A.hash,h(E),!E)throw new Error(`Unexpected tx: ${E}`)}}catch(t){if(l(!1),g({spec:c,brief:s,subtitle:u}),console.error(t),t.message){const n={error:t.message,brief:s};b&&Object.assign(n,b),e&&e(t,b),p(function(e,t){var n;const o=null===(n=ke[e])||void 0===n?void 0:n.symbol,i=[{error:"insufficient",msg:se._("Insufficient funds - Please retry after depositing more {EtherTokenSymbol} into your wallet",{EtherTokenSymbol:o})},{error:["External Swap execution Failed","Return amount is not enough"],msg:se._("Price impact exceeds the slippage tolerance you set. Try increasing the slippage tolerance.")},{error:"SafeERC20: low-level call failed",msg:se._("SafeERC20: low-level call failed. Please log a Zendesk support ticket or contact the DODO team.")},{error:["User denied","cancel","User rejected","user rejected"],msg:se._("User denied transaction signature.")},{error:["Cannot set properties of undefined (setting 'loadingDefauIts'){\"originalError\":{",'[ethjs-query]while formatting outputs from RPC\'["value":["code":-32000,"message":"header not found"))'],msg:se._("RPC node data exception")},{error:['execution reverted:FORCESTOP ["originalError"'],msg:se._("ForceStop exception")},{error:["replacement transaction underpriced","Gasprice too low","transaction underprice"],msg:se._("Gas price is too low, please adjust in your wallet and try again")},{error:["MINT_INVALID"],msg:se._("No ForceStop access")},{error:["NOT_PHASE_EXE"],msg:se._("Unable to SETTLE during the cooling-off period")},{error:["params specify an EIP-1559transaction but the currentnetwork does not support"],msg:se._("Wallet incompatibility")},{error:["ALREADY_SETTLED"],msg:se._("This CP has been settled by other addrs")},{error:["create RFQ order failed]:LESS_THAN_FEE_LIMIT"],msg:se._("Service update, please wait and try again")}];let r="";return i.some((e=>Array.isArray(e.error)?e.error.some((n=>t.indexOf(n)>-1&&(r=e.msg,!0))):t.indexOf(e.error)>-1&&(r=e.msg,!0))),r||t}(a,t.message))}return Pt.Failed}g({spec:c,brief:s,subtitle:u}),y(!1),l(!1);const O=Object.assign(Object.assign(Object.assign(Object.assign({brief:s},c),w),{tx:E,subtitle:u}),b);t&&t(E,O),f&&f();const k={brief:s,spec:c,tx:E,subtitle:u};if(d((e=>e.set(E,[k,Bt.Running]))),m)return Pt.Submitted;if(f&&f(),null==A?void 0:A.wait){const e=yield A.wait(1);if(y(!0),e.status===Ft.Success)return v&&v(E),o&&o(E,O),d((e=>e.set(E,[k,Bt.Success]))),Pt.Success}return y(!0),d((e=>e.set(E,[k,Bt.Failed]))),Pt.Failed}))),[i,a,l,r]),O=E((()=>({execute:A,requests:c,setShowing:g,waitingSubmit:s})),[A,c,g]),k=w((()=>{g(null),x&&(x(),C(void 0))}),[x]);return{showing:f,showingDone:b,transactionTx:m,errorMessage:u,setErrorMessage:p,closeShowing:k,ctxVal:O,requests:c}}function Kt(){const{requests:e}=Yt(),t=[];return null==e||e.forEach((function([e,n]){n===Bt.Running&&t.push(e)})),{runningRequests:t,isInflight:t.length>0}}const Gt=k({execute:()=>Promise.resolve(Pt.Canceled),requests:void 0,waitingSubmit:!1});function Yt(){return O(Gt)}var qt;function Xt(){return Xt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},Xt.apply(this,arguments)}var Zt=function(e){return x.createElement("svg",Xt({width:"33px",height:"33px",viewBox:"0 0 33 33",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),qt||(qt=x.createElement("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},x.createElement("g",{transform:"translate(-186.000000, -375.000000)",stroke:"currentColor",strokeWidth:4},x.createElement("g",{transform:"translate(18.000000, 291.000000)"},x.createElement("g",{transform:"translate(40.000000, 83.000000)"},x.createElement("path",{d:"M159,32 C159,15.9837423 146.016258,3 130,3"})))))))};function Qt({showingDone:e,errorMessage:t}){return re(a,t?{component:D,sx:{width:64,height:64,color:"error.main"}}:e?{component:N,sx:{width:64,height:64,color:"success.main"}}:{sx:{mx:"auto",border:e=>{var t;return`6px solid ${null===(t=e.palette)||void 0===t?void 0:t.background.input}`},borderRadius:"50%",width:"64px",height:"64px",position:"relative",animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}},children:re(a,{component:Zt,sx:{position:"absolute",top:"-6px",right:"-6px",color:"primary.main"}})})}function Jt({showingDone:e,showing:t}){return ie(a,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:[re(a,{sx:{mt:60},children:e?se._("{0} confirmed",{0:null==t?void 0:t.brief}):se._("{0} pending",{0:null==t?void 0:t.brief})}),(null==t?void 0:t.subtitle)?re(a,{sx:{mt:20,typography:"body2"},children:null==t?void 0:t.subtitle}):""]})}function en({isStarted:t,isEnded:n,tx:o}){const[i,r]=v(0),{chainId:s}=V(),l=E((()=>`https://${Ie[s||1]}/tx/${o}`),[o,s]),c=E((()=>{const e=Math.floor(i/60),t=i%60;return e?`${e}m ${t}s`:`${t}s`}),[i]),d=A();return C((()=>(r(0),d.current=setInterval((()=>{r((e=>e+1))}),1e3),()=>{clearInterval(d.current)})),[t]),C((()=>{clearInterval(d.current)}),[n]),ie(a,{sx:{mt:20,pt:20,display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.secondary",border:"solid 1px transparent",borderTopColor:"border.main"},children:[ie(a,{children:[re(e,{id:"Transaction Time:"}),c]}),ie(p,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},component:"a",href:l,target:"_blank",rel:"noopener noreferrer",children:[re(e,{id:"View on Etherscan"}),re(a,{component:_,sx:{width:16,height:16,ml:6}})]})]})}function tn(t){var{children:n}=t,o=Re(t,["children"]);const{ctxVal:i,showing:r,closeShowing:s,showingDone:l,errorMessage:c,transactionTx:d}=zt(o);return ie(Gt.Provider,{value:i,children:[n,re(kt,{open:!!r,onClose:s,children:ie(a,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",px:20,pb:20,flex:1,overflowY:"auto"},children:[ie(a,{children:[re(a,{sx:{textAlign:"center",pt:60},children:re(Qt,{showingDone:l,errorMessage:c})}),c?ie(a,{sx:{textAlign:"center",mt:60},children:[re(a,{children:re(e,{id:"Something went wrong."})}),re(a,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:c})]}):ie(ae,{children:[re(Jt,{showingDone:l,showing:r}),re(en,{isStarted:!!r,isEnded:l,tx:d})]})]}),re(u,{fullWidth:!0,size:u.Size.big,onClick:s,sx:{mt:20},children:re(e,c?{id:"Dismiss"}:{id:"Close"})})]})})]})}const nn=e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_GLOBAL_PROPS",payload:e})}));function on({width:e,height:t,feeRate:n,rebateTo:o,colorMode:i,apikey:r,defaultChainId:a,defaultToToken:s,defaultFromToken:l}){const c=T();C((()=>{i&&c((e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_COLOR_MODE",payload:e})})))(i))}),[i]),C((()=>{var e;a&&c((e=a,t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_CHAIN_ID",payload:e})}))))}),[a]),C((()=>{c(nn({height:t}))}),[t]),C((()=>{c(nn({width:e}))}),[e]),C((()=>{r&&c(nn({apikey:r}))}),[r]),C((()=>{n&&c(nn({feeRate:n}))}),[n]),C((()=>{o&&c(nn({rebateTo:o}))}),[o]),C((()=>{l&&c((e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_DEFAULT_FROM_TOKEN",payload:e})})))(l))}),[l]),C((()=>{s&&c((e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_DEFAULT_TO_TOKEN",payload:e})})))(s))}),[s])}function rn({refetch:e,interval:t}){let n;C((()=>(e(),clearTimeout(n),n=setInterval((()=>{e()}),null!=t?t:15e3),()=>clearTimeout(n))),[e])}function an({fromToken:e,toToken:t,chainId:n}){const[o,i]=v(!1),[r,a]=v(""),[s,l]=v(""),c=w((()=>{if(!n||!e||!t)return;i(!0);const o=[e,t];ue.post("https://api.dodoex.io/price-api/api/v1/price/current/batch",{networks:o.map((()=>(e=>Te[e]||Te[Ce.MAINNET])(n))),addresses:o.map((e=>e.address)),symbols:o.map((e=>e.symbol)),isCache:!0},{headers:{apikey:"dodofrontend777888ofopensource"}}).then((n=>{var o;i(!1);const r=null===(o=n.data)||void 0===o?void 0:o.data;r&&(a(r.find((t=>t.address===e.address)).price),l(r.find((e=>e.address===t.address)).price))})).catch((e=>{i(!1),console.error(e)}))}),[n,e,t]);return rn({refetch:c}),{loading:o,refetch:c,toFiatPrice:s,fromFiatPrice:r}}const sn=e=>(null!=e?e:je.getState()).settings.slippage,ln=e=>(null!=e?e:je.getState()).settings.ddl;var cn;function dn({toToken:e,fromToken:t,fromAmount:o,marginAmount:i}){const{account:r,chainId:a,provider:s}=V(),l=I(Me),c=E((()=>a||l),[a,l]),d=I(sn)||3,u=I(ln)||20,{feeRate:p,rebateTo:m,apikey:h}=I(Tt),f=E((()=>Math.floor(Date.now()/1e3)+60*u),[u]),[g,b]=v(cn.Initial),[y,x]=v(null),[C,A]=v(null),[O,k]=v(null),[T,L]=v(null),[R,S]=v(pe.from(0)),[D,N]=v(null),[_,B]=v(null),[P,F]=v(""),[j,M]=v(""),[U,H]=v(""),[W,$]=v(0),z=w((()=>Se(this,void 0,void 0,(function*(){if(!c||!t||!e)return;b(cn.Loading);const a={chainId:c,deadLine:f,apikey:h,slippage:d,source:"dodoV2AndMixWasm",toTokenAddress:e.address,toTokenDecimals:e.decimals,fromTokenAddress:t.address,fromTokenDecimals:t.decimals,userAddr:r||"0x0000000000000000000000000000000000000000",fromAmount:me(String(o||1),t.decimals).toString()};new n(i).isNaN()||(a.marginAmount=i),m&&p&&(a.rebateTo=m,a.fee=p);try{const e=(yield ue.get("https://api.dodoex.io/route-service/v2/widget/getdodoroute",{params:a})).data.data;(null==e?void 0:e.resAmount)?(b(cn.Success),x(e.resAmount),L(e.priceImpact),N(e.resPricePerFromToken),B(e.resPricePerToToken),A(e.baseFeeAmount),k(e.additionalFeeAmount),F(e.to),M(e.data),H(e.useSource),$(e.duration)):b(cn.Failed);const t=Le({tokenAmount:new n(o),tokenAddress:a.fromTokenAddress,chainId:a.chainId});if(!r||!s||!o)return;const i=yield Ut({from:r,to:e.to,value:t,data:e.data},s);i&&S(i)}catch(e){b(cn.Failed),console.error(e)}}))),[f,r,c,e,p,d,m,t,s,o,h]);rn({refetch:z});const K=E((()=>g!==cn.Loading&&o?y:null),[g,o,y]),G=function(){const{chainId:e,account:t}=V(),n=Yt();return w((({fromTokenAddress:o,parsedFromAmt:i,to:r,data:a,useSource:s,duration:l,ddl:c,gasLimit:d,subtitle:u})=>{const p=60*c,m=e||Ce.MAINNET,h=Le({tokenAmount:i,tokenAddress:o,chainId:m});s&&"weth"!==s.toLowerCase()&&d&&d.lt(3e4)&&console.debug("Warning: GasLimit less than the minimum!");const f={from:t,to:r,data:a,value:h,route:s,duration:l,ddlSecRel:p,gasLimit:d};n.execute(se._("Swap"),Object.assign({opcode:Wt.TX},f),u)}),[t,e])}(),Y=w((e=>{t&&o&&G({to:P,data:j,useSource:U,duration:W,ddl:u,fromTokenAddress:t.address,parsedFromAmt:new n(o),gasLimit:R,subtitle:e})}),[P,u,j,W,U,t,o,R]);return{status:g,refetch:z,priceImpact:T,executeSwap:Y,baseFeeAmount:C,resAmount:K,additionalFeeAmount:O,resPricePerToToken:_,resPricePerFromToken:D}}!function(e){e.Initial="Initial",e.Loading="Loading",e.Failed="Failed",e.Success="Success"}(cn||(cn={}));function un(e){ut(e),Xe(),Ze();const{provider:t,connector:n}=V();C((()=>{const t=e.defaultChainId||1;(null==n?void 0:n.connectEagerly)?n.connectEagerly(t):n.activate(t)}),[n]),C((()=>{const e=null==t?void 0:t.provider;e&&e.once&&e.once("chainChanged",(()=>{setTimeout((()=>{window.location.reload()}),200||100)}))}),[t]);const o=e.width||375,i=e.height||494;return on(Object.assign(Object.assign({},e),{width:o,height:i})),re(a,{sx:{width:o,height:i,overflow:"hidden",position:"relative",display:"flex",flexDirection:"column",minWidth:335,minHeight:494,borderRadius:16,backgroundColor:"background.paper"},className:"dodo-widget-container",children:re(tn,{...e,children:e.children})})}function pn(e){const t=m({mode:e.colorMode,theme:e.theme,lang:e.locale||"en-US"}),n=E((()=>e.defaultChainId||1),[e.defaultChainId]),o=ct({provider:e.provider,jsonRpcUrlMap:e.jsonRpcUrlMap,defaultChainId:n}),i=`${o.length}+${e.jsonRpcUrlMap?Object.entries(e.jsonRpcUrlMap):""}+${e.defaultChainId}+${n}`;return re(L,{store:je,children:re(_t,{locale:e.locale,children:re(h,{theme:t,children:ie(K,{connectors:o,children:[re(f,{container:".dodo-widget-container"}),re(un,{...e})]},i)})})})}function mn(e){const{width:t}=I(Tt),n=E((()=>{let e="";return"number"==typeof t?e=`${t}px`:t&&(e=t),e?`calc(${e} - 40px)`:"auto"}),[t]);return re(g,{container:document.querySelector(".dodo-widget-container"),maxWidth:n,...e})}function hn({onClick:e}){const t=s();return re(p,{sx:{width:"100%",position:"relative"},onClick:e,children:re(a,{component:l,sx:{width:36,height:36,borderRadius:"50%",backgroundColor:t.palette.background.input,border:`4px solid ${t.palette.background.paper}`,display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%) rotate(-90deg)"},children:re(a,{component:B,sx:{width:18,color:"text.secondary"}})})})}function fn({open:t,execute:o,onClose:i,toToken:r,fromToken:c,fromAmount:d,toAmount:p,priceImpact:m,clearFromAmt:h,baseFeeAmount:f,curToFiatPrice:g,curFromFiatPrice:b,pricePerFromToken:y,additionalFeeAmount:x}){var w,A;const O=s(),{isInflight:k}=Kt(),T=I(sn),L=E((()=>new n(m).gt(15)),[m]),[S,D]=v(!1),[N,_]=v(!1),[B,M]=v(!1);return C((()=>{k&&(i(),h(),M(!1))}),[k]),C((()=>{D(!1)}),[g]),re(kt,{open:t,onClose:()=>{M(!1),i()},title:re(e,{id:"Swap summary"}),children:ie(a,{sx:{margin:20,display:"flex",height:"100%",flexDirection:"column",borderTop:`1px solid ${O.palette.border.main}`},children:[ie(a,{sx:{py:20,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexDirection:"column",borderBottom:`1px solid ${O.palette.border.main}`},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[ie(a,{children:[ie(a,{sx:{display:"flex"},children:[re(wt,{width:16,height:16,address:null!==(w=null==c?void 0:c.address)&&void 0!==w?w:"",marginRight:6}),re(a,{children:`${d} ${null==c?void 0:c.symbol}`})]}),re(a,{sx:{mt:4,typography:"h6",color:O.palette.text.secondary},children:b?`$${fe({input:b,showDecimals:1})}`:"-"})]}),re(a,{sx:{width:16,mx:16},component:P}),ie(a,{children:[ie(a,{sx:{display:"flex"},children:[re(wt,{width:16,height:16,marginRight:6,address:null!==(A=null==r?void 0:r.address)&&void 0!==A?A:""}),re(a,{children:`${ge({input:p,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`})]}),re(a,{sx:{typography:"h6",mt:4,color:O.palette.text.secondary},children:g?`$${fe({input:g,showDecimals:1})}(${m}%)`:"-"})]})]}),re(a,{sx:{mt:12,typography:"h6"},children:`1 ${null==c?void 0:c.symbol} = ${ge({input:p,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`})]}),ie(a,{sx:{py:15,typography:"body2",borderBottom:`1px solid ${O.palette.border.main}`},children:[ie(a,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",color:O.palette.text.secondary},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(a,{sx:{width:16,mr:7},component:F}),re(e,{id:"Swap Detail"})]}),re(a,{component:l,children:re(a,{onClick:()=>_(!N),sx:{width:10,color:"text.secondary",transform:N?"rotateX(0deg)":"rotateX(180deg)"},component:R})})]}),ie(a,{sx:{mt:16,display:N?"initial":"none"},children:[ie(a,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(e,{id:"Basic Fee"}),re(mn,{title:re(e,{id:"Estimated service provider fees"}),ml:5})]}),re(a,{children:`${ge({input:f,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`})]}),ie(a,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(e,{id:"Additional Fee"}),re(mn,{title:re(e,{id:"Additional routing fees set by the Widget user"}),ml:5})]}),re(a,{children:`${ge({input:x,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`})]}),ie(a,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(e,{id:"Price Impact"}),re(mn,{title:re(e,{id:"Due to the market condition, market price and estimated price may have a slight difference"}),ml:5})]}),re(a,{children:`${m}%`})]}),ie(a,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(e,{id:"Slippage"}),re(mn,{title:re(e,{id:"High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:5})]}),re(a,{children:T})]})]})]}),re(a,{sx:{flex:1}}),L&&ie(a,{sx:{mb:14,display:"flex",cursor:"pointer",justifyContent:"center",alignItems:"center",typography:"h6"},onClick:()=>D(!S),children:[re(a,{sx:{mr:4,width:18,height:18,alignItems:"center"},children:re(a,S?{sx:{width:"100%",height:"100%",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"secondary.main"},children:re(a,{component:j,sx:{width:14,color:"#1a1a1b"}})}:{sx:{width:"100%",height:"100%",borderRadius:4,border:`1px solid ${O.palette.text.secondary}`}})}),re(a,{children:re(e,{components:{0:re(a,{component:"span",sx:{color:"error.main"}})},values:{priceImpact:m},id:"Price impact reaches <0>{priceImpact}</0>%, accept the quote"})})]}),re(u,{isLoading:B,disabled:L&&!S,fullWidth:!0,onClick:()=>{o(),M(!0)},children:re(e,B?{id:"Confirming"}:{id:"Confirm swap"})})]})})}function gn(e){var{sx:t,maxVal:n,decimals:i=2,onInputChange:r}=e,a=Re(e,["sx","maxVal","decimals","onInputChange"]);return s(),re(c,{...a,onChange:e=>{const t=0===e.target.value.length?null:xe(e.target.value,i),a=n&&t&&new o(t).gt(n)?n.toString():t;console.log("finalVal:",a),r&&r(a)}})}function bn({open:t,onClose:n}){const o=s(),i=T(),r=I(sn),l=I(ln),c=E((()=>Number(r)>=50),[r]);return re(kt,{open:t,onClose:n,title:re(e,{id:"Settings"}),children:ie(a,{sx:{mx:20},children:[ie(a,{sx:{py:20,borderTop:`1px solid ${o.palette.border.main}`},children:[ie(a,{sx:{mb:16,display:"flex",alignItems:"center"},children:[re(e,{id:"Slippage Tolerance"}),re(mn,{title:re(e,{id:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:7})]}),ie(a,{sx:{display:"flex",flexDirection:"column"},children:[re(gn,{fullWidth:!0,maxVal:100,value:r,placeholder:3..toString(),onInputChange:e=>{i((e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_SLIPPAGE",payload:e})})))(e))},suffix:re(a,{sx:{color:"text.disabled"},children:"%"}),height:36}),c&&re(a,{sx:{typography:"h6",mt:6,color:"error.main"},children:re(e,{id:"Maximum slippage do not exceed 50%"})})]})]}),ie(a,{sx:{py:20,borderTop:`1px solid ${o.palette.border.main}`},children:[ie(a,{sx:{mb:16,display:"flex",alignItems:"center"},children:[re(e,{id:"Transaction Deadline"}),re(mn,{title:re(e,{id:"If your transaction time exceeds the deadline, your transaction will be rescinded."}),ml:7})]}),re(gn,{value:l,fullWidth:!0,height:36,placeholder:se._("{DEFAULT_SWAP_DDL} minutes",{DEFAULT_SWAP_DDL:20}),onInputChange:e=>{i((e=>t=>Se(void 0,void 0,void 0,(function*(){t({type:"SET_TRANSACTION_DDL",payload:e})})))(e?Math.max(Number(e),1):""))}})]})]})})}function yn({toToken:t,fromToken:n,priceStatus:o,pricePerToToken:i,pricePerFromToken:r}){const[s,c]=v("-"),[d,u]=v(null),[p,m]=v("-"),[h,f]=v(null);C((()=>{c(null==n?void 0:n.symbol),m(null==t?void 0:t.symbol),u(i),f(r)}),[n,t,i,r]);const g=w((()=>{c(p),m(s),u(h),f(d)}),[s,d,p,h]);return re(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:{[cn.Initial]:"-",[cn.Loading]:ie(ae,{children:[re(b,{sx:{mr:5}}),re(e,{id:"Fetching best price..."})]}),[cn.Failed]:ie(ae,{children:[re(a,{component:M,sx:{width:15,mr:5,color:"warning.main"}}),re(e,{id:"Quote not available"})]}),[cn.Success]:ie(ae,{children:[re(a,{sx:{typography:"body2"},children:`1 ${s} = ${fe({input:h,showDecimals:4})} ${p}`}),re(a,{component:l,sx:{width:18,height:18,ml:6,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},children:re(a,{sx:{width:16,color:"text.secondary"},onClick:g,component:U})})]})}[o]})}function xn({open:t,onClose:n}){const o=I(Me);return re(kt,{title:re(e,{id:"Connect to your wallet"}),open:t,onClose:n,children:re(a,{sx:{mx:20,pb:20,border:"1px solid transparent",borderTopColor:"border.main"},children:Object.values(st).map((t=>ie(a,{sx:{display:"flex",alignItems:"center",flexDirection:"column",mt:20,p:20,backgroundColor:"background.tag",borderRadius:12,cursor:"pointer","&:hover":{backgroundColor:"hover.default"}},onClick:()=>{!function(e,t,n){var o;const i=lt[e];if(!i)throw new Error(`Unknown wallet type: ${e}`);const[r]=i;null===(o=r.activate(t))||void 0===o||o.catch((e=>{4001!==e.code?n(e):r.connectEagerly?r.connectEagerly(t):r.activate(t)}))}(t.type,o,(e=>{console.error(e)}))},children:[re(a,{component:t.icon,sx:{width:32,height:32}}),re(a,{sx:{mt:8,typography:"caption"},children:t.name}),re(a,{sx:{mt:4,typography:"body2",color:"text.secondary"},children:re(e,{id:"Connect to your {0} Wallet",values:{0:t.name}})})]},t.type)))})})}function vn(){const{connector:t}=V(),[n,o]=v(!1);return ie(ae,{children:[re(u,{size:u.Size.big,fullWidth:!0,onClick:()=>{t.deactivate?t.deactivate():t.resetState(),o(!0)},"data-testid":"connect-wallet-btn",children:re(e,{id:"Connect to a wallet"})}),re(xn,{open:n,onClose:()=>o(!1)})]})}var En;!function(e){e.Loading="Loading",e.Insufficient="ApprovalInsufficient",e.Approving="Approving",e.Sufficient="Sufficient",e.Unchecked="Unchecked"}(En||(En={}));const wn=({account:e,chainId:t,offset:o,contractAddress:i})=>{var r;const a=I(Me),s=E((()=>{var e;return Ve[null!==(e=t)&&void 0!==e?e:a]}),[t]),{isETH:l}=E((()=>we(t)),[t]),{DODO_APPROVE:c}=s||{},d=null!==(r=null!=i?i:c)&&void 0!==r?r:null,u=function(e){const{account:t}=V(),o=I(Me),i=I(mt),r=E((()=>ke[o]),[o]),a=w((o=>{var a;if(!t||!e)return null;if(o.symbol===r.symbol&&Ee(o.address,r.address))return new n(Vt);const s=null===(a=null==i?void 0:i[o.address.toLowerCase()])||void 0===a?void 0:a.tokenAllowances;return null!=s?s:null}),[t,e,r.symbol,r.address,i]);return a}(d),p=yt(),{runningRequests:m}=Kt(),h=I(bt),f=E((()=>{var e;return null===(e=ke[null!=t?t:a])||void 0===e?void 0:e.address}),[t]),g=w(((t,i,r)=>{if(!t)return En.Loading;const a=!!(null==m?void 0:m.find((e=>e.spec.opcode===Wt.Approval&&e.spec.token.address===(null==t?void 0:t.address)))),s=null!=r?r:t?p(t):null,l=t?u(t):null,c=new n(null!=i?i:0);if(!e)return En.Unchecked;if(!s||c.minus(null!=o?o:0).gt(s))return En.Unchecked;if(c.isZero())return En.Unchecked;return t.address===f?En.Sufficient:a?En.Approving:l&&c.minus(null!=o?o:0).gt(l)?En.Insufficient:En.Sufficient}),[p,u,e,o,d,t,h,m,f]),b=w((e=>{const t=e?u(e):null;return("USDT"===(null==e?void 0:e.symbol)||(null==e?void 0:e.address.toLowerCase())==="0x6426e6017968377529487E0ef0aA4E7759724e05".toLowerCase())&&null!==t&&t.gt(0)}),[u]),y=Yt(),x=T(),v=w(((t,o)=>Se(void 0,void 0,void 0,(function*(){if(!d||!e||!t)return;const i=(e=>{let t=e.symbol;return t.indexOf("DLP_")>-1&&(t=t.replace("DLP_","")),t.indexOf("DLP")>-1&&(t=t.replace("DLP","LP")),t})(t),r=o?new n(0):void 0,a=o?se._("Reset"):se._("Approve");var s;(yield y.execute(`${a} ${i}`,{opcode:Wt.Approval,token:t,contract:d,amt:r}))===Pt.Success&&x((s=null!=r?r:Vt,e=>Se(void 0,void 0,void 0,(function*(){e({type:"SET_ACCOUNT_ALLOWANCES",payload:s})}))))}))),[d,e,t,y,x]),C=w((e=>{const t=new n(0);if(!e)return t.toNumber();const o=p(e);if(!o)return t.toNumber();let i=o;const r=l?.1:.02;return f===(null==e?void 0:e.address)&&(i=o.gt(r)?o.minus(r):t),i.toNumber()}),[t,p,l]);return{getApprovalState:g,getPendingRest:b,getMaxBalance:C,submitApprove:v}};function Cn(){var t,o;const i=s(),{isInflight:c}=Kt(),{chainId:d,account:p}=V(),m=I(Me),h=I(gt),f=I(ft),{isETH:g}=E((()=>we(d)),[d]),y=E((()=>{var e;return null===(e=ke[null!=d?d:m])||void 0===e?void 0:e.address}),[d]),[x,A]=v(""),[O,k]=v(""),T=E((()=>r((e=>k(e)),600)),[]),[L,R]=v(null),[S,D]=v(null),[N,_]=v(!1),[B,F]=v(!1),{toFiatPrice:j,fromFiatPrice:U}=an({chainId:d,toToken:S,fromToken:L}),$=yt(),z=E((()=>L?$(L):null),[L,$]),{getApprovalState:K,submitApprove:G,getPendingRest:Y,getMaxBalance:q}=wn({account:p,chainId:d}),X=E((()=>Y(L)),[null==L?void 0:L.address,Y]),{marginAmount:Z}=function({fromToken:e,fromFiatPrice:t}){return{marginAmount:E((()=>{var o;const i=t,r=null!==(o=null==e?void 0:e.decimals)&&void 0!==o?o:6,a=null!=i?new n(500).div(i):new n(0),s=ve(a,r);return(s.lt(new n(1).times(new n(10).pow(r-3)))?new n(0):s).toString(10)}),[null==e?void 0:e.decimals,t])}}({fromToken:L,fromFiatPrice:U}),{resAmount:Q,priceImpact:J,executeSwap:ee,baseFeeAmount:te,additionalFeeAmount:ne,resPricePerToToken:oe,resPricePerFromToken:se,status:le}=dn({toToken:S,fromToken:L,marginAmount:Z,fromAmount:O}),ce=w((e=>{const t=e.toString();A(t),T(t)}),[A,T]);C((()=>{d&&(D(null),R(null),ce("")),h&&h.chainId===d&&D(h),f&&f.chainId===d&&R(f)}),[h,f,d,ce]);const de=w((()=>{R(S),D(L),ce("")}),[R,S,D,L,ce]),ue=w((e=>ce(q(L))),[ce,q,L]),pe=E((()=>(100*Number(J)).toFixed(2)),[J]),me=E((()=>O&&U?new n(U).multipliedBy(O):null),[U,O]),he=E((()=>Q&&j?new n(j).multipliedBy(Q):null),[j,Q]),be=E((()=>ie(a,{sx:{display:"flex",fontWeight:600,typography:"body2",alignItems:"center",justifyContent:"center"},children:[re(mn,{title:re(e,{id:"Due to the market condition, market price and estimated price may have a slight difference"}),mr:8}),ie(a,{sx:{display:"flex"},children:[re(e,{id:"Current price impact"}),ie(a,{sx:{color:i.palette.error.main,ml:4},children:[pe,"%"]})]})]})),[pe]),ye=E((()=>re(yn,{toToken:S,fromToken:L,priceStatus:le,pricePerToToken:oe,pricePerFromToken:se})),[S,L,le,oe,se]),xe=E((()=>!Ce[d||1]),[d]),Ee=E((()=>le===cn.Loading?re(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:ie(ae,{children:[re(b,{sx:{mr:5}}),re(e,{id:"Fetching best price..."})]})}):xe?ie(ae,{children:[re(a,{component:M,sx:{mr:6,width:16,color:"warning.main"}}),re(e,{id:"Unsupported network - switch to trade"})]}):x&&new n(pe).gt(15)?be:ye),[le,ye,x,be,pe,xe]),Ae=E((()=>{const t=K(L,O),o=t===En.Approving,i=t===En.Insufficient&&!X,r=g?.1:.02,a=y===(null==L?void 0:L.address),s=new n(z||0);return p?c?re(u,{fullWidth:!0,isLoading:!0,disabled:!0,children:re(e,{id:"Transaction Pending"})}):L&&S?i?re(u,{fullWidth:!0,disabled:o,onClick:()=>G(L),children:re(e,o?{id:"Approving"}:{id:"Approve"})}):new n(O).gt(0)?le===cn.Loading?re(u,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-fetch-price-btn",children:re(e,{id:"Fetching Price..."})}):Q?s.lt(O)||a&&s.lte(r)?re(u,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-insufficient-balance-btn",children:re(e,{id:"Insufficient balance"})}):re(u,{fullWidth:!0,onClick:()=>_(!0),"data-testid":"swap-review-btn",children:re(e,{id:"Review Swap"})}):re(u,{fullWidth:!0,disabled:!0,children:re(e,{id:"Quote not available"})}):re(u,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-enter-amount-btn",children:re(e,{id:"Enter an amount"})}):re(u,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-select-token-btn",children:re(e,{id:"Select Tokens"})}):re(vn,{})}),[g,p,O,S,Q,L,c,ee,X,G,le,z,K,y]),Oe=E((()=>L&&S?ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(wt,{token:L,sx:{width:16,height:16,mr:6}}),`${O} ${L.symbol}`,re(a,{component:P,sx:{width:12,height:12,mx:16}}),re(wt,{token:S,sx:{width:16,height:16,mr:6}}),`${ge({input:Q,decimals:null==S?void 0:S.decimals})} ${S.symbol}`]}):re(a,{})),[L,S,O,Q]);return ie(ae,{children:[ie(a,{sx:{display:"flex",justifyContent:"space-between",typography:"caption",margin:20},children:[re(e,{id:"Swap"}),re(a,{component:l,children:re(a,{component:H,onClick:()=>F(!0),sx:{width:19,height:19,color:"text.primary",cursor:"pointer"}})})]}),ie(a,{sx:{flex:1,padding:"0 20px 20px",overflowY:"auto"},children:[ie(a,{children:[re(Dt,{sx:{mb:4},token:L,amt:x,onMaxClick:ue,onInputChange:ce,showMaxBtn:!x,occupiedAddrs:[null!==(t=null==S?void 0:S.address)&&void 0!==t?t:""],fiatPriceTxt:me?`$${fe({input:me,showDecimals:1})}`:"-",onTokenChange:(e,t)=>{if(t)return de();R(e),ce("")}}),re(hn,{onClick:de}),re(Dt,{token:S,amt:new n(x).gt(0)?ge({input:Q,decimals:null==S?void 0:S.decimals}):"-",occupiedAddrs:[null!==(o=null==L?void 0:L.address)&&void 0!==o?o:""],fiatPriceTxt:he?`$${fe({input:he,showDecimals:1})}(${pe}%)`:"-",onTokenChange:(e,t)=>{if(t)return de();D(e)},readOnly:!0}),re(a,{sx:{py:12,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexWrap:"wrap"},children:Ee})]}),Ae,ie(a,{sx:{mt:13,display:"flex",typography:"h6",cursor:"pointer",justifyContent:"center",alignItems:"center",color:i.palette.text.disabled},onClick:()=>window.open("https://app.dodoex.io"),children:[re(a,{sx:{width:24,typography:"body2",transform:"translate(1px, 2px)","& path":{fill:i.palette.text.disabled}},component:W}),re(e,{id:"Powered by DODO protocol"})]})]}),re(fn,{toToken:S,fromToken:L,fromAmount:O,toAmount:Q,open:N,baseFeeAmount:te,priceImpact:pe,additionalFeeAmount:ne,curToFiatPrice:he,execute:()=>ee(Oe),clearFromAmt:()=>ce(""),curFromFiatPrice:me,pricePerFromToken:se,onClose:()=>_(!1)}),re(bn,{open:B,onClose:()=>F(!1)})]})}function An(e){return re(pn,{...e,children:re(Cn,{})})}function On(e){const t=document.getElementById("dodo-swap-widget");he(t).render(re(pn,{...e,children:re(Cn,{})}))}export{On as InitSwapWidget,An as SwapWidget};
|
|
1
|
+
import{Trans as e,I18nProvider as t}from"@lingui/react";import n,{BigNumber as o}from"bignumber.js";import{chunk as i,debounce as r}from"lodash";import{Box as a,useTheme as s,BaseButton as l,Input as c,SearchInput as d,Button as u,HoverOpacity as p,createTheme as m,ThemeProvider as h,CssBaseline as f,QuestionTooltip as g,RotatingIcon as b}from"@dodoex/components";import{getAddress as y}from"@ethersproject/address";import*as v from"react";import{useState as x,useMemo as E,useCallback as w,useEffect as C,useRef as A,useContext as O,createContext as T}from"react";import{useDispatch as k,useSelector as I,Provider as R}from"react-redux";import{CaretUp as S,Error as L,ErrorWarn as D,DoneBorder as _,ArrowTopRightBorder as N,ArrowBack as B,DoubleRight as P,DetailBorder as F,Done as j,Warn as M,Switch as U,Setting as H,Dodo as W}from"@dodoex/icons";import $ from"identicon.js";import{useWeb3React as V,initializeConnector as z,Web3ReactProvider as K}from"@web3-react/core";import{configureStore as G}from"@reduxjs/toolkit";import{combineReducers as Y}from"redux";import{Contract as q}from"@ethersproject/contracts";import{AddressZero as X}from"@ethersproject/constants";import{defaultAbiCoder as Z,Interface as Q}from"@ethersproject/abi";import{EIP1193 as J}from"@web3-react/eip1193";import{WalletConnect as ee}from"@web3-react/walletconnect";import{MetaMask as te}from"@web3-react/metamask";import{JsonRpcProvider as ne}from"@ethersproject/providers";import{Connector as oe}from"@web3-react/types";import{jsxs as ie,jsx as re,Fragment as ae}from"react/jsx-runtime";import{i18n as se}from"@lingui/core";import{VariableSizeList as le}from"react-window";import{en as ce,zh as de}from"make-plural/plurals";import ue from"axios";import{BigNumber as pe,parseFixed as me}from"@ethersproject/bignumber";import{createRoot as he}from"react-dom/client";function fe({input:e,showDecimals:t=4,showPrecisionDecimals:n=2,showIntegerOnly:i=!1,showDecimalsOnly:r=!1,noGroupSeparator:a=!1}){const s=new o(e);if(s.isNaN())return"-";let l=s.dp(t,o.ROUND_DOWN);return l.eq(0)&&(s.gt(0)||s.lt(0))&&(l=s.sd(null!=n?n:t,o.ROUND_DOWN)),i&&(l=l.integerValue(o.ROUND_DOWN)),r&&(l=l.minus(l.integerValue(o.ROUND_DOWN))),a?l.toFormat({decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0}):l.toFormat()}function ge({input:e,decimals:t,showPrecisionDecimals:n=2,noGroupSeparator:i}){if(null==e)return"-";const r=new o(e);if(r.isNaN())return"-";return fe({input:r,showDecimals:void 0===t?0:t>6?6:t>4?4:t,showPrecisionDecimals:n,noGroupSeparator:i})}function be(e){if("number"==typeof e)return be(new o(e));if(e.isNaN())return"NaN";if(e.isNegative())return`-${be(e.negated())}`;if(e.isZero())return"0";let t=e.integerValue(o.ROUND_FLOOR),n=e.minus(t),i="";for(;!t.isZero();){i=t.modulo(10).toString().toString()+i,t=t.idiv(10)}if(""===i&&(i="0"),n.isZero())return i;i+=".";let r=0;for(;!n.isZero()&&r<100;){const e=n.times(10),t=e.integerValue(o.ROUND_FLOOR);i+=t.toString(),n=e.minus(t),r+=1}return i}const ye=(e,t)=>{if("string"==typeof e&&!e.match(/[-+]?\d+(.+d+)?/))return e;const n=new o(e);if(t){let e=n.toFixed(t,o.ROUND_DOWN);return new o(e).isZero()&&(e=be(n.precision(t,o.ROUND_DOWN))),e}return be(n)},ve=(e,t)=>{let n=e;const o=n.match("[0-9。.]+");n=o&&o.length>0?o[0]:"",n=n.replace("。",".");let i=0;if(n){const e=n.split("."),t=0===e[0].length?["0"]:[e[0]];e.length>1?t[1]=e.slice(1,e.length).join(""):t[0].length>1&&"0"===t[0][0]&&(t[0]=t[0].slice(1,t[0].length)),t.length>1&&(i=t[1].length),n=t.join(".")}return t>=0&&i>t?ye(n,t):n},xe=(e,t)=>{if(0===e.length||0===t.length)return!1;if(t.length===e.length)return e.toLowerCase()===t.toLowerCase();const n=e.substring(2,e.length).toLowerCase(),o=t.substring(2,t.length).toLowerCase();return n.length>o.length?n.endsWith(o):o.endsWith(n)};const Ee=e=>{const t={isMainnet:1===e,isRinkeby:4===e,isGor:5===e};return Object.assign(Object.assign({},t),{isETH:t.isMainnet||t.isRinkeby||t.isGor})};var we;!function(e){e[e.MAINNET=1]="MAINNET",e[e.RINKEBY=4]="RINKEBY",e[e.GOERLI=5]="GOERLI",e[e.BSC=56]="BSC",e[e.HECO=128]="HECO",e[e.POLYGON=137]="POLYGON",e[e.ARBITRUM_ONE=42161]="ARBITRUM_ONE",e[e.ARBITRUM_RINKEBY=421611]="ARBITRUM_RINKEBY",e[e.AURORA=1313161554]="AURORA",e[e.MOONRIVER=1285]="MOONRIVER",e[e.OKCHAIN=66]="OKCHAIN",e[e.OPTIMISM=10]="OPTIMISM",e[e.BOBA=288]="BOBA",e[e.AVALANCHE=43114]="AVALANCHE",e[e.CRONOS=25]="CRONOS"}(we||(we={}));const Ce={[we.MAINNET]:["https://rpc.ankr.com/eth","https://eth-mainnet.public.blastapi.io","https://eth-rpc.gateway.pokt.network","https://main-rpc.linkpool.io"],[we.RINKEBY]:["https://rinkeby-light.eth.linkpool.io/"],[we.GOERLI]:["https://goerli.optimism.io/"],[we.BSC]:["https://bsc-dataseed1.binance.org","https://bsc-dataseed2.binance.org","https://bsc-dataseed3.binance.org","https://bsc-dataseed4.binance.org","https://bsc-dataseed1.defibit.io","https://bsc-dataseed2.defibit.io","https://bsc-dataseed3.defibit.io","https://bsc-dataseed4.defibit.io","https://bsc-dataseed1.ninicoin.io","https://bsc-dataseed2.ninicoin.io","https://bsc-dataseed3.ninicoin.io","https://bsc-dataseed4.ninicoin.io","https://bsc-dataseed.binance.org","https://rpc.ankr.com/bsc","https://bscrpc.com","https://bsc.mytokenpocket.vip","https://binance.nodereal.io","https://rpc-bsc.bnb48.club"],[we.HECO]:["https://http-mainnet.hecochain.com","https://pub001.hg.network/rpc"],[we.POLYGON]:["https://polygon-rpc.com","https://rpc-mainnet.matic.network","https://matic-mainnet.chainstacklabs.com","https://rpc-mainnet.maticvigil.com","https://rpc-mainnet.matic.quiknode.pro","https://matic-mainnet-full-rpc.bwarelabs.com","https://matic-mainnet-archive-rpc.bwarelabs.com","https://poly-rpc.gateway.pokt.network","https://rpc.ankr.com/polygon","https://polygon-mainnet.public.blastapi.io"],[we.ARBITRUM_ONE]:["https://arb1.arbitrum.io/rpc","https://rpc.ankr.com/arbitrum"],[we.ARBITRUM_RINKEBY]:["https://rinkeby.arbitrum.io/rpc"],[we.AURORA]:["https://mainnet.aurora.dev/"],[we.MOONRIVER]:["https://rpc.api.moonriver.moonbeam.network","https://moonriver.api.onfinality.io/rpc?apikey=673e1fae-c9c9-4c7f-a3d5-2121e8274366","https://moonriver.api.onfinality.io/public","https://moonriver.public.blastapi.io"],[we.OKCHAIN]:["https://exchainrpc.okex.org","https://okc-mainnet.gateway.pokt.network/v1/lb/6275309bea1b320039c893ff"],[we.OPTIMISM]:["https://mainnet.optimism.io","https://optimism-mainnet.public.blastapi.io"],[we.BOBA]:["https://mainnet.boba.network","https://boba-mainnet.gateway.pokt.network/v1/lb/623ad21b20354900396fed7f","https://lightning-replica.boba.network"],[we.AVALANCHE]:["https://api.avax.network/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://ava-mainnet.public.blastapi.io/ext/bc/C/rpc"],[we.CRONOS]:["https://evm.cronos.org","https://cronos-rpc.heavenswail.one","https://evm-cronos.crypto.org","https://cronosrpc-1.xstaking.sg","https://cronos-rpc.elk.finance"]},Ae={symbol:"ETH",address:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",name:"Ether",decimals:18,showDecimals:4,wrappedTokenSymbol:"WETH"},Oe={[we.MAINNET]:Object.assign(Object.assign({},Ae),{wrappedTokenAddress:"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}),[we.RINKEBY]:Object.assign(Object.assign({},Ae),{wrappedTokenAddress:"0xB26c0d8Be2960c70641A95A9195BE1f59Ac83aC0"}),[we.GOERLI]:Object.assign(Object.assign({},Ae),{wrappedTokenAddress:"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6"}),[we.OPTIMISM]:Object.assign(Object.assign({},Ae),{wrappedTokenAddress:"0x4200000000000000000000000000000000000006"}),[we.CRONOS]:Object.assign(Object.assign({},Ae),{symbol:"CRO",name:"Cronos",wrappedTokenSymbol:"WCRO",wrappedTokenAddress:"0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23"}),[we.BOBA]:Object.assign(Object.assign({},Ae),{wrappedTokenAddress:"0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000"}),[we.BSC]:Object.assign(Object.assign({},Ae),{symbol:"BNB",name:"BNB",wrappedTokenSymbol:"WBNB",wrappedTokenAddress:"0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"}),[we.OKCHAIN]:Object.assign(Object.assign({},Ae),{symbol:"OKT",name:"OKT",wrappedTokenSymbol:"WOKT",wrappedTokenAddress:"0x8F8526dbfd6E38E3D8307702cA8469Bae6C56C15"}),[we.HECO]:Object.assign(Object.assign({},Ae),{symbol:"HT",name:"HT",showDecimals:6,wrappedTokenSymbol:"WHT",wrappedTokenAddress:"0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f"}),[we.POLYGON]:Object.assign(Object.assign({},Ae),{symbol:"MATIC",name:"MATIC",showDecimals:6,wrappedTokenSymbol:"WMATIC",wrappedTokenAddress:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"}),[we.MOONRIVER]:Object.assign(Object.assign({},Ae),{symbol:"MOVR",name:"MOVR",showDecimals:6,wrappedTokenSymbol:"WMOVR",wrappedTokenAddress:"0x98878b06940ae243284ca214f92bb71a2b032b8a"}),[we.ARBITRUM_ONE]:Object.assign(Object.assign({},Ae),{name:"Ethereum",showDecimals:6,wrappedTokenAddress:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"}),[we.ARBITRUM_RINKEBY]:Object.assign(Object.assign({},Ae),{name:"Ether",showDecimals:6,wrappedTokenAddress:"0xEBbc3452Cc911591e4F18f3b36727Df45d6bd1f9"}),[we.AURORA]:Object.assign(Object.assign({},Ae),{name:"Ethereum",showDecimals:6,wrappedTokenAddress:"0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB"}),[we.AVALANCHE]:Object.assign(Object.assign({},Ae),{symbol:"AVAX",name:"Avalanche",showDecimals:6,wrappedTokenSymbol:"WAVAX",wrappedTokenAddress:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7"})},Te={[we.MAINNET]:"ethereum",[we.RINKEBY]:"rinkeby",[we.GOERLI]:"goerli",[we.OPTIMISM]:"optimism",[we.CRONOS]:"cronos",[we.BOBA]:"boba",[we.BSC]:"bsc",[we.OKCHAIN]:"okex-chain",[we.HECO]:"heco",[we.POLYGON]:"polygon",[we.MOONRIVER]:"moonriver",[we.ARBITRUM_ONE]:"arbitrum",[we.ARBITRUM_RINKEBY]:"arb-rinkeby",[we.AURORA]:"aurora",[we.AVALANCHE]:"avalanche"},ke={[we.MAINNET]:"etherscan.io",[we.RINKEBY]:"rinkeby.etherscan.io",[we.GOERLI]:"goerli.etherscan.io",[we.OPTIMISM]:"optimistic.etherscan.io",[we.CRONOS]:"cronoscan.com",[we.BOBA]:"blockexplorer.boba.network",[we.BSC]:"bscscan.com",[we.OKCHAIN]:"www.oklink.com/okexchain",[we.HECO]:"hecoinfo.com",[we.POLYGON]:"polygonscan.com",[we.MOONRIVER]:"moonriver.moonscan.io",[we.ARBITRUM_ONE]:"arbiscan.io",[we.ARBITRUM_RINKEBY]:"testnet.arbiscan.io",[we.AURORA]:"aurorascan.dev",[we.AVALANCHE]:"snowtrace.io"};function Ie(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function Re(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{l(o.next(e))}catch(e){r(e)}}function s(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}const Se={colorMode:"dark",slippage:3..toString(),ddl:20};var Le=(e=Se,t)=>{switch(t.type){case"SET_COLOR_MODE":return Object.assign(Object.assign({},e),{colorMode:t.payload});case"SET_SLIPPAGE":return Object.assign(Object.assign({},e),{slippage:t.payload});case"SET_TRANSACTION_DDL":return Object.assign(Object.assign({},e),{ddl:t.payload});default:return e}};const De={chainId:we.MAINNET,latestBlockNumber:0};var _e=(e=De,t)=>{switch(t.type){case"SET_CHAIN_ID":return Object.assign(Object.assign({},e),{chainId:t.payload});case"SET_BLOCK_NUMBER":return Object.assign(Object.assign({},e),{latestBlockNumber:t.payload});default:return e}};const Ne={tokenList:[],popularTokenList:[],ethBalance:void 0,accountBalances:{},balanceLoadings:{},slippageWithTokens:[]};var Be,Pe=(e=Ne,t)=>{switch(t.type){case"SET_TOKEN_LIST":return Object.assign(Object.assign({},e),{tokenList:t.payload});case"SET_POPULAR_TOKEN_LIST":return Object.assign(Object.assign({},e),{popularTokenList:t.payload});case"SET_SLIPPAGE_WITH_TOKENS":return Object.assign(Object.assign({},e),{slippageWithTokens:t.payload});case"SET_ETH_BALANCE":return Object.assign(Object.assign({},e),{ethBalance:t.payload});case"SET_DEFAULT_FROM_TOKEN":return Object.assign(Object.assign({},e),{defaultFromToken:t.payload});case"SET_DEFAULT_TO_TOKEN":return Object.assign(Object.assign({},e),{defaultToToken:t.payload});case"SET_ACCOUNT_BALANCES":return Object.assign(Object.assign({},e),{accountBalances:Object.assign(Object.assign({},e.accountBalances),t.payload)});case"SET_ACCOUNT_ALLOWANCES":const n=e.accountBalances;return Object.keys(n).map((e=>{n[e].tokenAllowances=t.payload})),Object.assign(Object.assign({},e),{accountBalances:n});case"SET_BALANCE_LOADINGS":return Object.assign(Object.assign({},e),{balanceLoadings:Object.assign(Object.assign({},e.balanceLoadings),t.payload)});default:return e}};!function(e){e.Initial="Initial",e.Pending="Pending",e.ApproveSuccess="ApproveSuccess",e.TxSuccess="TxSuccess",e.Failed="Failed"}(Be||(Be={}));const Fe={height:void 0,width:void 0,apikey:"",feeRate:0,rebateTo:"",isReverseRouting:!1,contractStatus:Be.Initial};const je={settings:Se,wallet:De,globals:Fe,token:Ne},Me=G({reducer:Y({settings:Le,wallet:_e,token:Pe,globals:(e=Fe,t)=>"SET_GLOBAL_PROPS"===t.type?Object.assign(Object.assign({},e),t.payload):e}),middleware:e=>e({serializableCheck:{ignoredActions:["SET_ACCOUNT_BALANCES","SET_ETH_BALANCE"],ignoredPaths:["token.accountBalances","token.ethBalance"]}}),preloadedState:je}),Ue=e=>(null!=e?e:Me.getState()).wallet.chainId,He=e=>(null!=e?e:Me.getState()).wallet.latestBlockNumber,We=e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_ACCOUNT_BALANCES",payload:e})})),$e=e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_BALANCE_LOADINGS",payload:e})}));var Ve=[{constant:!0,inputs:[],name:"getCurrentBlockTimestamp",outputs:[{name:"timestamp",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{components:[{name:"target",type:"address"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate",outputs:[{name:"blockNumber",type:"uint256"},{name:"returnData",type:"bytes[]"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"getLastBlockHash",outputs:[{name:"blockHash",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"addr",type:"address"}],name:"getEthBalance",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"getCurrentBlockDifficulty",outputs:[{name:"difficulty",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"getCurrentBlockGasLimit",outputs:[{name:"gaslimit",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"getCurrentBlockCoinbase",outputs:[{name:"coinbase",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"blockNumber",type:"uint256"}],name:"getBlockHash",outputs:[{name:"blockHash",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"}],ze={[we.MAINNET]:{MULTI_CALL:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",DODO_APPROVE:"0xCB859eA579b28e02B87A1FDE08d087ab9dbE5149",ERC20_HELPER:"0xD9ef2d1583e8Aa196123e773BE38B539a4d149df"},[we.RINKEBY]:{MULTI_CALL:"0xb7E1C577f95959a3eD11f9281702850328b4e0e4",DODO_APPROVE:"0xcC8d87A7C747eeE4242045C47Ef25e0A81D56ae3",ERC20_HELPER:"0x6A42091d713A67E25a1D11aeE14E7AEB96E0331f"},[we.GOERLI]:{MULTI_CALL:"0x696E25A5e2AEd1C55E6d6Cfa0532Bbda9020165d",DODO_APPROVE:"0xC9143e54021f4a6d33b9b89DBB9F458AaEdd56FB",ERC20_HELPER:"0x24549FC74B3076A962624A26370ed556c467F74C"},[we.BSC]:{MULTI_CALL:"0x1Ee38d535d541c55C9dae27B12edf090C608E6Fb",DODO_APPROVE:"0xa128Ba44B2738A558A1fdC06d6303d52D3Cef8c1",ERC20_HELPER:"0x566651Ad34f6306872FaC5fB95bbF4C9beE8D8F2"},[we.HECO]:{MULTI_CALL:"0x76a328B3440B9276a31523e731B34082df7a6f1A",DODO_APPROVE:"0x68b6c06Ac8Aa359868393724d25D871921E97293",ERC20_HELPER:"0x270C2abC692Dd476B860CCbDfD6D8146BF61f8D8"},[we.POLYGON]:{MULTI_CALL:"0xc9eD9B18e447e600238fe50e944B9062B664DEa4",DODO_APPROVE:"0x292E6b2e054e1157df71C1C9510265CA8C0c7672",ERC20_HELPER:"0xfd24312Ec7871A6D1a31e454D5AbB16c6c25a9b3"},[we.ARBITRUM_ONE]:{MULTI_CALL:"0xF718F2bd590E5621e53f7b89398e52f7Acced8ca",DODO_APPROVE:"0xA867241cDC8d3b0C07C85cC06F25a0cD3b5474d8",ERC20_HELPER:"0x7C062B9C584fA6eC2504270790D38240A2c5fE72"},[we.ARBITRUM_RINKEBY]:{MULTI_CALL:"0x696E25A5e2AEd1C55E6d6Cfa0532Bbda9020165d",DODO_APPROVE:"0x5BaF16d57620Cb361F622232F3cb4090e35F3da2",ERC20_HELPER:"0x5B2fd46E6E3Ff1E479d651ec0b210882Aa9871dF"},[we.AURORA]:{MULTI_CALL:"0x989DcAA95801C527C5B73AA65d3962dF9aCe1b0C",DODO_APPROVE:"0x335aC99bb3E51BDbF22025f092Ebc1Cf2c5cC619",ERC20_HELPER:"0xE8C9A78725D0451FA19878D5f8A3dC0D55FECF25"},[we.MOONRIVER]:{MULTI_CALL:"0x2ff2CeE6E9359F9eA1cF2f51d18bF9F2045447E4",DODO_APPROVE:"0xE8C9A78725D0451FA19878D5f8A3dC0D55FECF25",ERC20_HELPER:"0x6373ceB657C83C91088d328622573FB766064Ac4"},[we.OKCHAIN]:{MULTI_CALL:"0x5e84190a270333aCe5B9202a3F4ceBf11b81bB01",DODO_APPROVE:"0x7737fd30535c69545deeEa54AB8Dd590ccaEBD3c",ERC20_HELPER:"0x4775b1858f1e417C9609D455C3Ad8751ec01daC4"},[we.OPTIMISM]:{MULTI_CALL:"0xb98Ac2fEFc8b73aeAE33D02BB00c26E12afCa9Df",DODO_APPROVE:"0xa492d6eABcdc3E204676f15B950bBdD448080364",ERC20_HELPER:"0x42E456ea0dd7538ea103fBb1d0388D14C97bB5b2"},[we.BOBA]:{MULTI_CALL:"0xD56281EF996B6B29874C77D2e1464216E8043127",DODO_APPROVE:"0x8F8Dd7DB1bDA5eD3da8C9daf3bfa471c12d58486",ERC20_HELPER:"0x9FCFD9ff955D36856F8EE480471B05488C0eB5cA"},[we.AVALANCHE]:{MULTI_CALL:"0x97f0153E7F5749640aDF3Ff9CFC518b79D6Fe53b",DODO_APPROVE:"0xCFea63e3DE31De53D68780Dd65675F169439e470",ERC20_HELPER:"0xC3528D128CC227fd60793007b5e3FdF7c2945282"},[we.CRONOS]:{MULTI_CALL:"0x4f4408D78F9E9e242c17C635FbD0f1952951c917",DODO_APPROVE:"0x9B736bB8f336f61E16454DCA4dE130703D151042",ERC20_HELPER:"0xbd2F5c60cf7d60daD2106ceD4D21b90722761f14"}};function Ke(e,t,...n){return Re(this,void 0,void 0,(function*(){const o=[];for(const e of n)for(const t of e)t.callData&&o.push(t.callData);const i=yield function(e,t,n){return Re(this,void 0,void 0,(function*(){const o=yield Ge(e,t,n),i=new Map;for(const{req:e,resp:t}of o)i.set(e,t);return e.map((e=>({req:e,resp:i.get(e)})))}))}(o,e,t),r=new Map;for(const{req:e,resp:t}of i)r.set(e,null==t?void 0:t.result);return n.map((e=>e.filter((e=>!e.callData||r.get(e.callData))).map(((e,t)=>e.processor(e.callData?r.get(e.callData):null,t)))))}))}function Ge(e,t,n){return Re(this,void 0,void 0,(function*(){let o=[e];e.length>800&&(o=i(e,800));let r=[];const a=o.map((e=>Re(this,void 0,void 0,(function*(){const o=e.map((e=>[e.to,e.data])),i={data:t.interface.encodeFunctionData("aggregate",[o]),to:n};let a;try{a=yield t.provider.call(i)}catch(o){const i=e.length;if(i>20){const o=Math.floor(i/2),[a,s]=yield Promise.all([Ge(e.slice(0,o),t,n),Ge(e.slice(o,i),t,n)]);r=[...r,...a,...s]}else{const e="[sendCallReqs] error";console.error(e,o)}}if(void 0===a)throw new Error("Unexpected batch result");const[s,l]=Z.decode(["uint256","bytes[]"],a);if(e.length!==l.length)throw new Error("Unexpected length mismatch");return l.map(((t,n)=>({resp:{result:t},req:e[n]})))}))));return(yield Promise.allSettled(a)).filter((e=>"fulfilled"===e.status)).forEach((({value:e})=>{r=[...r,...e]})),r}))}function Ye(e,t,n,o){if(!function(e){try{return y(e)}catch(e){return!1}}(e)||e===X)throw Error(`Invalid 'address' parameter '${e}'.`);return new q(e,t,function(e,t){return t?function(e,t){return e.getSigner(t).connectUnchecked()}(e,t):e}(n,o))}function qe(){const{provider:e,account:t,chainId:n}=V(),[o,i]=x(!1),r=E((()=>ze[n]),[n]),a=w(((n,o)=>{if(e)return Ye(n,o,e,t)}),[e,t]),s=w((e=>{if(!r)return;const{MULTI_CALL:t}=r,n=a(t,Ve);return(()=>Re(this,void 0,void 0,(function*(){if(n){i(!0);try{const[o]=yield Ke(n,t,e);return o}catch(e){console.error("Contract: useMultiContract is error",e)}i(!1)}})))()}),[r,a]);return{getContract:a,contractConfig:r,call:s,loading:o}}var Xe=[{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"user",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"isERC20",outputs:[{internalType:"bool",name:"isOk",type:"bool"},{internalType:"string",name:"symbol",type:"string"},{internalType:"string",name:"name",type:"string"},{internalType:"uint256",name:"decimals",type:"uint256"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"allownance",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"user",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"judgeERC20",outputs:[{internalType:"string",name:"symbol",type:"string"},{internalType:"string",name:"name",type:"string"},{internalType:"uint256",name:"decimals",type:"uint256"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"allownance",type:"uint256"}],stateMutability:"view",type:"function"}];function Ze(){const{provider:e,account:t}=V(),o=k(),i=I(He);C((()=>{(()=>{Re(this,void 0,void 0,(function*(){if(!e||!t)return;const i=yield e.getBalance(t);o((e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_ETH_BALANCE",payload:e})})))(new n(i.toString()).div(1e18)))}))})()}),[e,t,o,i])}function Qe(){const{provider:e,chainId:t}=V(),n=k();C((()=>{const o=e=>{n((e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_BLOCK_NUMBER",payload:e})})))(e))};return(()=>{Re(this,void 0,void 0,(function*(){if(!e||!t)return;const n=yield e.getBlockNumber();o(n),e.on("block",o)}))})(),()=>{null==e||e.off("block",o)}}),[e,n,t])}function Je(e){return Number.parseInt(e,16)}class et extends oe{constructor(e,t){super(e),this.customProvider=t,t.on("connect",(({chainId:e})=>{this.actions.update({chainId:Je(e)})})).on("disconnect",(e=>{var t;null===(t=this.onError)||void 0===t||t.call(this,e),this.actions.resetState()})).on("chainChanged",(e=>{this.actions.update({chainId:Je(e)})})).on("accountsChanged",(e=>{this.actions.update({accounts:e})}))}activate(){return Re(this,void 0,void 0,(function*(){this.actions.startActivation();const e=this.customProvider;try{const[{chainId:t},n]=yield Promise.all([e.getNetwork(),e.listAccounts()]);this.actions.update({chainId:t,accounts:n})}catch(e){throw this.actions.resetState(),e}}))}}function tt([e,t]){return[e,t]}var nt;function ot(){return ot=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},ot.apply(this,arguments)}var it,rt;function at(){return at=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},at.apply(this,arguments)}var st;!function(e){e.INTEGRATOR="integrator",e.METAMASK="metamask",e.WALLET_CONNECT="walletConnect"}(st||(st={}));const lt={[st.METAMASK]:{name:"MetaMask",type:st.METAMASK,icon:function(e){return v.createElement("svg",ot({height:355,viewBox:"0 0 397 355",width:397,xmlns:"http://www.w3.org/2000/svg"},e),nt||(nt=v.createElement("g",{fill:"none",fillRule:"evenodd",transform:"translate(-1 -1)"},v.createElement("path",{d:"m114.622644 327.195472 52.004717 13.810198v-18.05949l4.245283-4.249292h29.716982v21.246459 14.872523h-31.839624l-39.268868-16.997169z",fill:"#cdbdb2"}),v.createElement("path",{d:"m199.528305 327.195472 50.943397 13.810198v-18.05949l4.245283-4.249292h29.716981v21.246459 14.872523h-31.839623l-39.268868-16.997169z",fill:"#cdbdb2",transform:"matrix(-1 0 0 1 483.96227 0)"}),v.createElement("path",{d:"m170.872644 287.889523-4.245283 35.056657 5.306604-4.249292h55.18868l6.367925 4.249292-4.245284-35.056657-8.490565-5.311615-42.452832 1.062323z",fill:"#393939"}),v.createElement("path",{d:"m142.216984 50.9915022 25.471698 59.4900858 11.674528 173.158643h41.391511l12.735849-173.158643 23.349056-59.4900858z",fill:"#f89c35"}),v.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),v.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),v.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),v.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),v.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 56.25-39.305949z",fill:"#eb8f35"}),v.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),v.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),v.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),v.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),v.createElement("path",{d:"m114.622644 327.195472 56.25-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3"}),v.createElement("path",{d:"m229.245286 327.195472 55.18868-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3",transform:"matrix(-1 0 0 1 513.679252 0)"}),v.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),v.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),v.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"}),v.createElement("g",{transform:"matrix(-1 0 0 1 399.056611 0)"},v.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),v.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),v.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),v.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),v.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 55.18868-38.243626z",fill:"#eb8f35"}),v.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),v.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),v.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),v.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),v.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),v.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),v.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"})))))},link:"https://metamask.io"},[st.WALLET_CONNECT]:{name:"WalletConnect",type:st.WALLET_CONNECT,icon:function(e){return v.createElement("svg",at({height:512,viewBox:"0 0 512 512",width:512,xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),it||(it=v.createElement("radialGradient",{id:"a",cx:"0%",cy:"50%",r:"100%"},v.createElement("stop",{offset:0,stopColor:"#5d9df6"}),v.createElement("stop",{offset:1,stopColor:"#006fff"}))),rt||(rt=v.createElement("g",{fill:"none",fillRule:"evenodd"},v.createElement("path",{d:"m256 0c141.384896 0 256 114.615104 256 256s-114.615104 256-256 256-256-114.615104-256-256 114.615104-256 256-256z",fill:"url(#a)"}),v.createElement("path",{d:"m64.6917558 37.7088298c51.5328072-50.2784397 135.0839942-50.2784397 186.6167992 0l6.202057 6.0510906c2.57664 2.5139218 2.57664 6.5897948 0 9.1037177l-21.215998 20.6995759c-1.288321 1.2569619-3.3771 1.2569619-4.665421 0l-8.534766-8.3270205c-35.950573-35.0754962-94.237969-35.0754962-130.188544 0l-9.1400282 8.9175519c-1.2883217 1.2569609-3.3771016 1.2569609-4.6654208 0l-21.2159973-20.6995759c-2.5766403-2.5139229-2.5766403-6.5897958 0-9.1037177zm230.4934852 42.8089117 18.882279 18.4227262c2.576627 2.5139103 2.576642 6.5897593.000032 9.1036863l-85.141498 83.070358c-2.576623 2.513941-6.754182 2.513969-9.33084.000066-.00001-.00001-.000023-.000023-.000033-.000034l-60.428256-58.957451c-.64416-.628481-1.68855-.628481-2.33271 0-.000004.000004-.000008.000007-.000012.000011l-60.4269683 58.957408c-2.5766141 2.513947-6.7541746 2.51399-9.3308408.000092-.0000151-.000014-.0000309-.000029-.0000467-.000046l-85.14386774-83.071463c-2.57663928-2.513921-2.57663928-6.589795 0-9.1037163l18.88231264-18.4226955c2.5766393-2.5139222 6.7541993-2.5139222 9.3308397 0l60.4291347 58.9582758c.6441608.62848 1.6885495.62848 2.3327103 0 .0000095-.000009.0000182-.000018.0000277-.000025l60.4261065-58.9582508c2.576581-2.51398 6.754142-2.5140743 9.33084-.0002103.000037.0000354.000072.0000709.000107.0001063l60.429056 58.9583548c.644159.628479 1.688549.628479 2.332709 0l60.428079-58.9571925c2.57664-2.5139231 6.754199-2.5139231 9.330839 0z",fill:"#fff",fillRule:"nonzero",transform:"translate(98 160)"}))))}}},ct={};function dt({provider:e,jsonRpcUrlMap:t,defaultChainId:n}){const o=console.error,i=E((()=>function(e,t){if(t){if(ne.isProvider(t))return tt(z((e=>new et(e,t))));if(ne.isProvider(t.provider))throw new Error("Eip1193Bridge is experimental: pass your ethers Provider directly");return tt(z((n=>new J({actions:n,provider:t,onError:e}))))}}(o,e)),[o,e]),r=E((()=>function(e){return tt(z((t=>new te({actions:t,onError:e}))))}(o)),[o]),a=E((()=>t?Object.assign(Object.assign({},Ce),t):Ce),[t]),s=E((()=>function(e,t,n,o){return tt(z((i=>new ee({actions:i,options:{rpc:t,qrcode:e},onError:o,defaultChainId:n}))))}(!0,a,n,o)),[a,n,o]);return i&&(ct[st.INTEGRATOR]=i),ct[st.METAMASK]=r,ct[st.WALLET_CONNECT]=s,Object.values(ct)}function ut(){const{chainId:e}=V(),t=I(Ue);return E((()=>e||t||1),[e,t])}function pt({tokenList:e,popularTokenList:t}){const o=k(),[i,r]=x([]),{account:a}=V(),s=ut(),l=I(He),c=E((()=>(null==t?void 0:t.filter((e=>e.chainId===s)))||[]),[t,s]);!function({tokenList:e,addresses:t,blockNumber:o}){const{account:i}=V(),r=k(),a=E((()=>[...(null==e?void 0:e.map((e=>e.address)))||[],...t||[]].map((e=>e.toLocaleLowerCase()))),[e,t]),{getContract:s,contractConfig:l,call:c}=qe(),[d,u]=x(),p=E((()=>{if(!i||!a.length||!l)return;const{DODO_APPROVE:e,ERC20_HELPER:t}=l,o=s(t,Xe);if(!o)return;let c={};const d=a.map((r=>(c[r]=!0,{callData:{data:o.interface.encodeFunctionData("isERC20",[r,i,e]),to:t},processor:e=>{const t=new Q(Xe).decodeFunctionResult("isERC20",e),{balance:o,isOk:i}=t,a=parseInt(t.decimals),s=new n(10).pow(a),l=new n(t.allownance.toString()).div(s);return i?{address:r,decimals:a,symbol:t.symbol,name:t.name,balance:new n(o.toString()).div(s),allowance:l}:{address:r,balance:new n(0),allowance:new n(0)}}})));return r($e(c)),d}),[i,s,a]);C((()=>{(()=>{Re(this,void 0,void 0,(function*(){if(!p)return;const e=yield c(p),t={};e&&(e.forEach((e=>{t[e.address.toLocaleLowerCase()]={tokenBalances:e.balance,tokenAllowances:e.allowance}})),r(We(t))),u(e);let n={};a.forEach((e=>{n[e]=!1})),r($e(n))}))})()}),[p,o])}({addresses:E((()=>{const e=i.map((({address:e})=>e));return null==t||t.forEach((({address:t})=>{e.includes(t)||e.push(t)})),e}),[i,t]),blockNumber:l}),C((()=>{(()=>{Re(this,void 0,void 0,(function*(){let t=[];if(e)t=e;else{t=(yield import("./tokenList-4ef211de.js")).default}const n=s,i=t.filter((e=>e.chainId===n));r(i),o((e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_TOKEN_LIST",payload:e})})))(i))}))})()}),[e,o,s]),C((()=>{o(We({}))}),[a,s]),C((()=>{o((e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_POPULAR_TOKEN_LIST",payload:e})})))(c))}),[c,o])}const mt=e=>(null!=e?e:Me.getState()).token.tokenList,ht=e=>(null!=e?e:Me.getState()).token.accountBalances,ft=e=>(null!=e?e:Me.getState()).token.ethBalance||new n(NaN),gt=e=>(null!=e?e:Me.getState()).token.defaultFromToken,bt=e=>(null!=e?e:Me.getState()).token.defaultToToken,yt=e=>(null!=e?e:Me.getState()).token.balanceLoadings;function vt(){const{account:e,chainId:t}=V(),n=I(ht),o=I(ft),i=E((()=>Oe[t||1]),[t]),r=w((t=>{var r;if(!e)return null;if(t.symbol===i.symbol&&xe(t.address,i.address))return!o||(null==o?void 0:o.isNaN())?null:o;const a=null===(r=n[t.address.toLocaleLowerCase()])||void 0===r?void 0:r.tokenBalances;return!a||(null==a?void 0:a.isNaN())?null:a}),[n,o,e]);return r}var xt;function Et(e,t,n,o=0){if(n&&(e=e.toLocaleLowerCase(),t=t.toLocaleLowerCase()),e===t)return xt.fully+o;const i=e.indexOf(t);return 0===i?xt.prefix+o:i>0?xt.other+o:xt.none}!function(e){e[e.fully=1]="fully",e[e.prefix=2]="prefix",e[e.other=3]="other",e[e.none=0]="none"}(xt||(xt={}));function wt({value:e,onChange:t,occupiedAddrs:o,hiddenAddrs:i,showAddrs:r}){const[a,s]=x(""),l=I(mt),c=ut(),d=vt(),u=E((()=>new Set(i?i.map((e=>e.toLowerCase())):void 0)),[i]),p=E((()=>r?new Set(r.map((e=>e.toLowerCase()))):void 0),[r]),m=w((e=>e.filter((e=>{if(e.chainId!==c)return!1;let t=!0;return t=p?p.has(e.address.toLowerCase()):!u.has(e.address.toLowerCase()),t}))),[p,c,u]),h=w((t=>{if(null===t)return null;const i=[];a?t.forEach((e=>{const t=((e,t,{matchAddress:n}={})=>{if(!t)return 0;const o=t.toLocaleLowerCase();let i=0;n&&e.address.toLocaleLowerCase()===o&&(i=1),i||(i=Et(e.symbol.toLocaleLowerCase(),o,!1,1));if(i)e.name.toLocaleLowerCase()===o&&(i=xt.fully+1);else{let t=Et(e.name.toLocaleLowerCase(),o,!1,10);t=t===xt.fully+10?xt.fully+1:t,i=t}return i})(e,a,{matchAddress:!0});t&&i.push({sort:t,token:e})})):t.forEach((e=>{i.push({sort:0,token:e})}));const r=[];return i.sort(((t,i)=>{const r=t.token,a=i.token;if(e){if(r.address===e.address)return-1;if(a.address===e.address)return 1}if(null==o?void 0:o.includes(r.address))return-1;if(null==o?void 0:o.includes(a.address))return 1;const s=d&&d(r)||new n(0),l=d&&d(a)||new n(0);return s.eq(l)?t.sort!==i.sort?t.sort>i.sort?1:-1:r.symbol.localeCompare(a.symbol):s.gt(l)?-1:1})).some((e=>!!(a&&r.length>21)||(r.push(e.token),!1))),r}),[a,d,o,e]),f=w((e=>{const n=e.address.toLowerCase();t(e,!!(null==o?void 0:o.some((e=>e.toLowerCase()===n))))}),[t,o]),g=E((()=>{const e=m(l);return h(e)||[]}),[l,m,h]);return{filter:a,setFilter:s,showTokenList:g,onSelectToken:f}}function Ct({width:e=24,height:t=24,marginRight:n=8,url:o,zIndex:i,cross:r,address:s,token:l,sx:c}){const[d,u]=x(!1),[p,m]=x(""),[h,f]=x(""),[g,b]=x(!1),y=w((()=>u(!0)),[]);let v=function(e){const t=I(mt),{chainId:n}=V();return E((()=>{if(!e)return;let o=t.find((({address:t,chainId:o})=>o===n&&t===e));return o||(o=t.find((({address:t})=>t===e))),o}),[e,t,n])}(s);l&&(v=l);const A=s||(null==v?void 0:v.address),O=null==v?void 0:v.symbol,T=null==O?void 0:O.charAt(0).toUpperCase(),k=E((()=>{const e=null==v?void 0:v.logoURI;return o||e||""}),[o,v]);return C((()=>{b(!1)}),[A,k]),C((()=>{r&&(k?function(e,t){const n=new XMLHttpRequest;let o;n.onload=function(){const e=new FileReader;e.onloadend=function(){t(e.result)},e.readAsDataURL(n.response)},n.onerror=function(){t()};try{o=new URL(e)}catch(e){}finally{n.open("GET",o||e),n.responseType="blob",n.send()}}(k,(e=>{m(e)})):m(""))}),[k,r]),C((()=>{try{let t=A;if(t&&t.length<15&&(t=t.padEnd(15,"0")),t){const n=new $(t,{size:e,format:"svg",margin:.2,background:[255,234,4,255]}).toString();f(`data:image/svg+xml;base64,${n}`)}}catch(e){console.error("generate Identicon error: ",e)}}),[A,e]),ie(a,{sx:Object.assign({position:"relative",display:"flex",alignItems:"center",justifyContent:"center",minWidth:e,width:e,height:t,marginRight:n,zIndex:i},c||{}),style:{width:e,height:t},children:[!d&&re(a,{sx:{typography:"ht",height:"100%",width:"100%",borderRadius:"50%",border:"transparent 2px solid",borderColor:"text.primary",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"center"},children:T}),re(a,{component:"img",src:!(r?p:k)||g?h:r?p:k,onLoad:y,onError:e=>{const t=e.target;A&&h&&b(!0),t.onerror=null},sx:{position:"absolute",top:"0",bottom:"0",left:"0",right:"0",borderRadius:"50%",overflow:"hidden",width:"100%",height:"100%"}})]})}function At({token:t,onClick:n}){var o,i;const r=s();return ie(a,{component:l,sx:{display:"flex",alignItems:"center",color:r.palette.text.primary,typography:"h5",fontWeight:600},onClick:e=>{n&&n(e)},"data-testid":"swap-select-token-btn",children:[(null==t?void 0:t.address)?ie(ae,{children:[re(Ct,{address:null!==(o=null==t?void 0:t.address)&&void 0!==o?o:"",marginRight:6}),re(a,{children:null!==(i=null==t?void 0:t.symbol)&&void 0!==i?i:"-"})]}):re(e,{id:"SELECT TOKEN"}),re(a,{sx:{ml:7,width:12,transform:"rotateX(180deg)"},component:S})]})}function Ot({onClick:t,balance:n,decimals:o,address:i,showMaxBtn:r}){const{palette:c}=s();return ie(a,{sx:{display:"flex",typography:"body2",color:c.text.secondary},children:[re(e,{id:"Balance:"})," ",i?ge({input:n,decimals:Math.min(o||4,4)}):"-",r&&n&&n.gt(0)&&re(a,{component:l,sx:{ml:6,color:(null==n?void 0:n.gt(0))?c.primary.main:c.text.disabled,cursor:i&&t?"pointer":"unset"},onClick:()=>t&&t(n?n.toString():""),children:re(e,{id:"Max"})})]})}function Tt({readOnly:e,sx:t,value:n,decimals:o,onChange:i,suffix:r,withClear:d,onFocus:u,placeholder:p}){const m=s(),h=E((()=>r||(d&&n&&i?re(a,{component:l,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},onClick:()=>{i&&i("")},children:re(a,{component:L,sx:{width:12,color:"text.primary"}})}):void 0)),[i,r,m.palette.text.primary,n,d]);return ie(a,{sx:Object.assign({mt:12,display:"flex",justifyContent:"space-between",alignItems:"center"},t),"data-testid":"number-input-wrapper",children:[re(c,{fullWidth:!0,value:n,readOnly:e,placeholder:p||"0.00",onFocus:u,onChange:e=>{const t=e.target.value,n=0===t.length?"":ve(t,o);i&&i(n)},sx:{width:"inherit",border:"none","& .MuiInput-input":{fontSize:24,border:"none",outline:"none",height:24,padding:0,color:"text.primary","&::placeholder":{fontSize:24,color:"text.disabled"}}}}),!e&&n&&h]})}function kt({open:e,onClose:t,title:n,rightSlot:o,canBack:i=!0,children:r,height:s,testId:l}){return ie(a,{sx:{position:"absolute",top:e?0:"100%",transition:"top 300ms",zIndex:1,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",backgroundColor:"background.paper",borderRadius:16,height:s},"data-testid":l,"data-active":e?"1":"0",children:[n?ie(a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:20},children:[re(a,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:n}),o,!o&&i&&re(a,{component:L,sx:{color:"text.secondary",cursor:"pointer"},onClick:t})]}):"",r]})}const It=e=>(null!=e?e:Me.getState()).globals;function Rt({token:e,disabled:t,onClick:n}){return ie(a,{sx:Object.assign({display:"inline-flex",alignItems:"center",p:8,border:"solid 1px",typography:"body2",borderRadius:8},t?{borderColor:"transparent",backgroundColor:"border.disabled",cursor:"auto"}:{borderColor:"border.main",cursor:"pointer","&:hover":{backgroundColor:"hover.default"}}),onClick:()=>{t||n()},children:[re(Ct,{token:e}),e.symbol]})}function St({token:e,disabled:t,style:n,onClick:o}){const i=vt()(e),r=i?fe({input:i}):"";return ie(a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2",px:6,py:5,borderRadius:8,cursor:t?"auto":"pointer",opacity:t?.5:1,"&:hover":{backgroundColor:"hover.default"}},style:n,onClick:()=>{t||o()},"data-testid":"token-picker-item",children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(Ct,{token:e}),ie(a,{children:[re(a,{sx:{fontWeight:600,textAlign:"left"},children:e.symbol}),re(a,{sx:{mt:4,textAlign:"left"},children:r})]})]}),re(a,{sx:{color:"text.secondary"},children:e.name})]})}function Lt({value:e,onChange:t,occupiedAddrs:n,hiddenAddrs:o,showAddrs:i,visible:r}){var s;const l=ut(),c=I((e=>((e,t)=>(null!=t?t:Me.getState()).token.popularTokenList.filter((({chainId:t})=>e===t)))(l,e))),{showTokenList:u,filter:p,setFilter:m,onSelectToken:h}=wt({value:e,onChange:t,occupiedAddrs:n,hiddenAddrs:o,showAddrs:i}),f=A(null),g=A(null),[b,y]=x(0);C((()=>{r&&f.current&&y(f.current.offsetHeight-34)}),[f,r]);const v=w((({index:t,style:n})=>{const o=!!(null==c?void 0:c.length);if(0===t&&o)return re(a,{sx:{position:"relative",display:"flex",gap:8,flexWrap:"wrap",pb:32,"&::after":{content:'""',position:"absolute",bottom:16,left:0,right:0,height:"1px",backgroundColor:"border.main"}},ref:g,style:Object.assign(Object.assign({},n),{visibility:n.height?"visible":"hidden",height:n.height?n.height:"auto"}),children:c.map((t=>re(Rt,{token:t,disabled:(null==e?void 0:e.address)===t.address,onClick:()=>h(t)},t.address)))});const i=u[o?t-1:t];return re(St,{token:i,disabled:!!e&&e.address===i.address,style:n,onClick:()=>h(i)})}),[u,c,g,e]),E=w((e=>{var t;if(0===e&&(null==c?void 0:c.length)){const e=(null===(t=g.current)||void 0===t?void 0:t.offsetHeight)||0;return e<=52?0:e}return 52}),[g,c]);return ie(a,{sx:{display:"flex",flexDirection:"column",px:20,flex:1},children:[re(d,{fullWidth:!0,height:48,value:p,onChange:e=>m(e.target.value),clearValue:()=>m(""),placeholder:se._("Enter the token symbol or address")}),re(a,{sx:{mt:16,pb:16,flex:1,minHeight:64},ref:f,children:re(le,{height:b,itemCount:u.length+((null==c?void 0:c.length)?1:0),itemSize:E,width:"100%",className:"token-list",children:v},null===(s=g.current)||void 0===s?void 0:s.offsetHeight)})]})}function Dt({open:t,value:n,onClose:o,occupiedAddrs:i,onTokenChange:r}){const{height:a}=I(It);return re(kt,{height:a,open:t,onClose:o,title:re(e,{id:"Select a token"}),testId:"token-picker-wrapper",children:re(Lt,{value:n,visible:t,onChange:r,occupiedAddrs:i})})}function _t({sx:e,amt:t,token:n,readOnly:o,showMaxBtn:i,onMaxClick:r,fiatPriceTxt:l,occupiedAddrs:c,onInputFocus:d,onTokenClick:u,onInputChange:p,onTokenChange:m}){const h=s(),f=vt(),[g,b]=x(!1),y=n?f(n):null;return ie(a,{sx:Object.assign({width:"100%",minHeight:133,padding:20,borderRadius:12,overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",backgroundColor:h.palette.background.input},e),children:[ie(a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[re(At,{token:n,onClick:()=>b(!0)}),re(Ot,{balance:y,onClick:r,showMaxBtn:i,address:null==n?void 0:n.address,decimals:null==n?void 0:n.decimals})]}),re(Tt,{value:t,onFocus:d,onChange:p,readOnly:o,withClear:!0}),re(a,{sx:{mt:4,typography:"body2",color:h.palette.text.secondary},children:l}),re(Dt,{value:n,open:g,occupiedAddrs:c,onClose:()=>{u&&u(),b(!1)},onTokenChange:(e,t)=>{m(e,t),b(!1)}})]})}const Nt={"en-US":ce,"zh-CN":de,pseudo:ce};function Bt({locale:e,children:n}){return C((()=>{(()=>{Re(this,void 0,void 0,(function*(){yield function(e="en-US"){return Re(this,void 0,void 0,(function*(){se.loadLocaleData(e,{plurals:()=>Nt[e]});try{const t=yield import(`./locales/${e}.js`);se.load(e,t.messages||t.default.messages)}catch(e){}se.activate(e)}))}(e)}))})()}),[e]),re(t,{i18n:se,children:n})}var Pt,Ft,jt;!function(e){e[e.Running=0]="Running",e[e.Success=1]="Success",e[e.Failed=2]="Failed",e[e.Warning=3]="Warning"}(Pt||(Pt={})),function(e){e.Canceled="canceled",e.Failed="failed",e.Success="success",e.Submitted="submitted"}(Ft||(Ft={})),function(e){e[e.Failed=0]="Failed",e[e.Success=1]="Success"}(jt||(jt={}));var Mt,Ut=[{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"guy",type:"address"},{name:"wad",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}];!function(e){e[e.Failed=0]="Failed",e[e.Success=1]="Success",e[e.Warning=2]="Warning"}(Mt||(Mt={}));const Ht=(e,t)=>Re(void 0,void 0,void 0,(function*(){const{value:n,from:o,to:i,data:r}=e,a={from:o,to:i,value:n,data:r};n&&!/^0x0*$/.test(n)||delete a.value;try{return(yield t.estimateGas(a)).add(5e4)}catch(e){t.call(a).then((e=>{if("test"!==process.env.NODE_ENV)throw new Error("Unexpected issue with estimating the gas. Please try again.")})).catch((e=>{if("test"!==process.env.NODE_ENV)throw e}))}return null})),Wt=(e,t)=>Re(void 0,void 0,void 0,(function*(){try{return yield t.getSigner().sendTransaction(e)}catch(e){throw 4001===(null==e?void 0:e.code)?new Error(se._("Transaction rejected.")):e}}));var $t,Vt;!function(e){e.Approval="APPROVAL",e.TX="TX",e.TypedSign="TypedSign"}($t||($t={})),function(e){e.Normal="Normal",e.Privacy="Privacy",e.LimitOrder="LimitOrder",e.RFQ="RFQ"}(Vt||(Vt={}));const zt=new n(2).pow(256).minus(1),Kt=e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_GLOBAL_PROPS",payload:e})}));function Gt({onTxFail:e,onTxSubmit:t,onTxSuccess:o}={}){const{account:i,provider:r}=V(),a=ut(),[s,l]=x(!1),[c,d]=x(new Map),u=k(),[p,m]=x(null),[h,f]=x(""),[g,b]=x(null),[y,v]=x(!1),[C,A]=x(),O=w(((s,c,p,h=!1,g,y,x,E)=>Re(this,void 0,void 0,(function*(){if(f(""),m(""),!i||!r)throw new Error("Submission: Cannot execute step when the wallet is disconnected");let w,C,O;A((()=>x)),l(!1);try{if(l(!0),c.opcode===$t.Approval)O=yield((e,t,o,i,r,a)=>Re(void 0,void 0,void 0,(function*(){const s=Ye(e,Ut,r,a).interface.encodeFunctionData("approve",[o,i.toFixed()]),l={from:t,to:e,data:s,value:`0x${new n("0").toString(16)}`,gasLimit:void 0},c=yield Ht(l,r);return c&&(l.gasLimit=c),yield Wt(l,r)})))(c.token.address,i,c.contract,c.amt||zt,r,i),w=O.hash,f(w);else{if(c.opcode!==$t.TX)throw new Error(`Op ${c.opcode} not implemented!`);if(""===c.to)throw new Error("Submission: malformed to");if(0===c.data.length)throw new Error("Submission: malformed data");if(0===c.data.indexOf("0x")&&c.data.length<=2)throw new Error("Submission: malformed data");if(C={value:c.value,data:c.data,to:c.to,gasLimit:c.gasLimit,from:i,chainId:a},!C.gasLimit)try{const e=yield Ht(C,r);e&&(C.gasLimit=e)}catch(e){console.debug(e)}if(O=yield Wt(C,r),w=O.hash,f(w),!w)throw new Error(`Unexpected tx: ${w}`)}}catch(t){if(l(!1),b({spec:c,brief:s,subtitle:p}),console.error(t),t.message){u(Kt({contractStatus:Be.Failed}));const n={error:t.message,brief:s};y&&Object.assign(n,y),e&&e(t,y),m(function(e,t){var n;const o=null===(n=Oe[e])||void 0===n?void 0:n.symbol,i=[{error:"insufficient",msg:se._("Insufficient funds - Please retry after depositing more {EtherTokenSymbol} into your wallet",{EtherTokenSymbol:o})},{error:["External Swap execution Failed","Return amount is not enough"],msg:se._("Price impact exceeds the slippage tolerance you set. Try increasing the slippage tolerance.")},{error:"SafeERC20: low-level call failed",msg:se._("SafeERC20: low-level call failed. Please log a Zendesk support ticket or contact the DODO team.")},{error:["User denied","cancel","User rejected","user rejected"],msg:se._("User denied transaction signature.")},{error:["Cannot set properties of undefined (setting 'loadingDefauIts'){\"originalError\":{",'[ethjs-query]while formatting outputs from RPC\'["value":["code":-32000,"message":"header not found"))'],msg:se._("RPC node data exception")},{error:['execution reverted:FORCESTOP ["originalError"'],msg:se._("ForceStop exception")},{error:["replacement transaction underpriced","Gasprice too low","transaction underprice"],msg:se._("Gas price is too low, please adjust in your wallet and try again")},{error:["MINT_INVALID"],msg:se._("No ForceStop access")},{error:["NOT_PHASE_EXE"],msg:se._("Unable to SETTLE during the cooling-off period")},{error:["params specify an EIP-1559transaction but the currentnetwork does not support"],msg:se._("Wallet incompatibility")},{error:["ALREADY_SETTLED"],msg:se._("This CP has been settled by other addrs")},{error:["create RFQ order failed]:LESS_THAN_FEE_LIMIT"],msg:se._("Service update, please wait and try again")}];let r="";return i.some((e=>Array.isArray(e.error)?e.error.some((n=>t.indexOf(n)>-1&&(r=e.msg,!0))):t.indexOf(e.error)>-1&&(r=e.msg,!0))),r||t}(a,t.message))}return Ft.Failed}b({spec:c,brief:s,subtitle:p}),v(!1),l(!1);const T=Object.assign(Object.assign(Object.assign(Object.assign({brief:s},c),C),{tx:w,subtitle:p}),y);u(Kt({contractStatus:Be.Pending})),t&&t(w,T),g&&g();const k={brief:s,spec:c,tx:w,subtitle:p};if(d((e=>e.set(w,[k,Pt.Running]))),h)return Ft.Submitted;if(g&&g(),null==O?void 0:O.wait){const e=yield O.wait(1);if(v(!0),e.status===jt.Success)return"TX"===T.opcode&&u(Kt({contractStatus:Be.TxSuccess})),"APPROVAL"===T.opcode&&u(Kt({contractStatus:Be.ApproveSuccess})),E&&E(w),o&&o(w,T),d((e=>e.set(w,[k,Pt.Success]))),Ft.Success}return v(!0),d((e=>e.set(w,[k,Pt.Failed]))),Ft.Failed}))),[i,a,l,r]),T=E((()=>({execute:O,requests:c,setShowing:b,waitingSubmit:s})),[O,c,b]),I=w((()=>{b(null),C&&(C(),A(void 0))}),[C]);return{showing:g,showingDone:y,transactionTx:h,errorMessage:p,setErrorMessage:m,closeShowing:I,ctxVal:T,requests:c}}function Yt(){const{requests:e}=Xt(),t=[];return null==e||e.forEach((function([e,n]){n===Pt.Running&&t.push(e)})),{runningRequests:t,isInflight:t.length>0}}const qt=T({execute:()=>Promise.resolve(Ft.Canceled),requests:void 0,waitingSubmit:!1});function Xt(){return O(qt)}var Zt;function Qt(){return Qt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},Qt.apply(this,arguments)}var Jt=function(e){return v.createElement("svg",Qt({width:"33px",height:"33px",viewBox:"0 0 33 33",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),Zt||(Zt=v.createElement("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},v.createElement("g",{transform:"translate(-186.000000, -375.000000)",stroke:"currentColor",strokeWidth:4},v.createElement("g",{transform:"translate(18.000000, 291.000000)"},v.createElement("g",{transform:"translate(40.000000, 83.000000)"},v.createElement("path",{d:"M159,32 C159,15.9837423 146.016258,3 130,3"})))))))};function en({showingDone:e,errorMessage:t}){return re(a,t?{component:D,sx:{width:64,height:64,color:"error.main"}}:e?{component:_,sx:{width:64,height:64,color:"success.main"}}:{sx:{mx:"auto",border:e=>{var t;return`6px solid ${null===(t=e.palette)||void 0===t?void 0:t.background.input}`},borderRadius:"50%",width:"64px",height:"64px",position:"relative",animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}},children:re(a,{component:Jt,sx:{position:"absolute",top:"-6px",right:"-6px",color:"primary.main"}})})}function tn({showingDone:e,showing:t}){return ie(a,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:[re(a,{sx:{mt:60},children:e?se._("{0} confirmed",{0:null==t?void 0:t.brief}):se._("{0} pending",{0:null==t?void 0:t.brief})}),(null==t?void 0:t.subtitle)?re(a,{sx:{mt:20,typography:"body2"},children:null==t?void 0:t.subtitle}):""]})}function nn({isStarted:t,isEnded:n,tx:o}){const[i,r]=x(0),{chainId:s}=V(),l=E((()=>`https://${ke[s||1]}/tx/${o}`),[o,s]),c=E((()=>{const e=Math.floor(i/60),t=i%60;return e?`${e}m ${t}s`:`${t}s`}),[i]),d=A();return C((()=>(r(0),d.current=setInterval((()=>{r((e=>e+1))}),1e3),()=>{clearInterval(d.current)})),[t]),C((()=>{clearInterval(d.current)}),[n]),ie(a,{sx:{mt:20,pt:20,display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.secondary",border:"solid 1px transparent",borderTopColor:"border.main"},children:[ie(a,{children:[re(e,{id:"Transaction Time:"}),c]}),ie(p,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},component:"a",href:l,target:"_blank",rel:"noopener noreferrer",children:[re(e,{id:"Tx"}),re(a,{component:N,sx:{width:16,height:16,ml:6}})]})]})}function on(t){var{children:n}=t,o=Ie(t,["children"]);const{ctxVal:i,showing:r,closeShowing:s,showingDone:l,errorMessage:c,transactionTx:d}=Gt(o),p=k();return ie(qt.Provider,{value:i,children:[n,re(kt,{open:!!r,onClose:s,children:ie(a,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",px:20,pb:20,flex:1,overflowY:"auto"},children:[ie(a,{children:[re(a,{sx:{textAlign:"center",pt:60},children:re(en,{showingDone:l,errorMessage:c})}),c?ie(a,{sx:{textAlign:"center",mt:60},children:[re(a,{children:re(e,{id:"Something went wrong."})}),re(a,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:c})]}):ie(ae,{children:[re(tn,{showingDone:l,showing:r}),re(nn,{isStarted:!!r,isEnded:l,tx:d})]})]}),re(u,{fullWidth:!0,size:u.Size.big,onClick:()=>{p(Kt({contractStatus:Be.Initial})),s()},sx:{mt:20},children:re(e,c?{id:"Dismiss"}:{id:"Close"})})]})})]})}function rn({token:e,fiatPrice:t}){return{marginAmount:E((()=>{var i;const r=null!==(i=null==e?void 0:e.decimals)&&void 0!==i?i:6,a=((e,t,n)=>{const i=new o(e).times(new o(10).pow(t));return n?i:i.dp(0)})(null!=t?new n(500).div(t):new n(0),r);return(a.lt(new n(1).times(new n(10).pow(r-3)))?new n(0):a).toString(10)}),[null==e?void 0:e.decimals,t])}}function an({width:e,height:t,feeRate:n,rebateTo:o,colorMode:i,apikey:r,defaultChainId:a,defaultToToken:s,defaultFromToken:l}){const c=k();C((()=>{i&&c((e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_COLOR_MODE",payload:e})})))(i))}),[i]),C((()=>{var e;a&&c((e=a,t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_CHAIN_ID",payload:e})}))))}),[a]),C((()=>{c(Kt({height:t}))}),[t]),C((()=>{c(Kt({width:e}))}),[e]),C((()=>{r&&c(Kt({apikey:r}))}),[r]),C((()=>{n&&c(Kt({feeRate:n}))}),[n]),C((()=>{o&&c(Kt({rebateTo:o}))}),[o]),C((()=>{l&&c((e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_DEFAULT_FROM_TOKEN",payload:e})})))(l))}),[l]),C((()=>{s&&c((e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_DEFAULT_TO_TOKEN",payload:e})})))(s))}),[s])}function sn({refetch:e,interval:t}){let n;C((()=>(e(),clearTimeout(n),n=setInterval((()=>{e()}),null!=t?t:15e3),()=>clearTimeout(n))),[e])}function ln({fromToken:e,toToken:t,chainId:n}){const[o,i]=x(!1),[r,a]=x(""),[s,l]=x(""),c=w((()=>{if(!n||!e||!t)return;i(!0);const o=[e,t];ue.post("https://api.dodoex.io/price-api/api/v1/price/current/batch",{networks:o.map((()=>(e=>Te[e]||Te[we.MAINNET])(n))),addresses:o.map((e=>e.address)),symbols:o.map((e=>e.symbol)),isCache:!0},{headers:{apikey:"dodofrontend777888ofopensource"}}).then((n=>{var o;i(!1);const r=null===(o=n.data)||void 0===o?void 0:o.data;r&&(a(r.find((t=>t.address===e.address)).price),l(r.find((e=>e.address===t.address)).price))})).catch((e=>{i(!1),console.error(e)}))}),[n,e,t]);return sn({refetch:c}),{loading:o,refetch:c,toFiatPrice:s,fromFiatPrice:r}}const cn=e=>(null!=e?e:Me.getState()).settings.slippage,dn=e=>(null!=e?e:Me.getState()).settings.ddl;var un;function pn({toToken:e,fromToken:t,fromAmount:n,toAmount:o,marginAmount:i}){const{account:r,chainId:a,provider:s}=V(),l=I(Ue),c=E((()=>a||l),[a,l]),d=I(cn)||3,u=I(dn)||20,{feeRate:p,rebateTo:m,apikey:h,isReverseRouting:f}=I(It),g=E((()=>Math.floor(Date.now()/1e3)+60*u),[u]),[b,y]=x(un.Initial),[v,C]=x(null),[A,O]=x(""),[T,k]=x(null),[R,S]=x(null),[L,D]=x(null),[_,N]=x(pe.from(0)),[B,P]=x(null),[F,j]=x(null),[M,U]=x(""),[H,W]=x(""),[$,z]=x(""),[K,G]=x(0),Y=w((()=>Re(this,void 0,void 0,(function*(){if(!c||!t||!e)return;if(!f&&!n)return;if(f&&!o)return;y(un.Loading);const i={chainId:c,deadLine:g,apikey:h,slippage:d,source:"dodoV2AndMixWasm",toTokenAddress:e.address,toTokenDecimals:e.decimals,fromTokenAddress:t.address,fromTokenDecimals:t.decimals,userAddr:r||"0x0000000000000000000000000000000000000000"};f?i.toAmount=me(String(o||1),e.decimals).toString():i.fromAmount=me(String(n||1),t.decimals).toString(),m&&p&&(i.rebateTo=m,i.fee=p);try{const e=(yield ue.get("https://api.dodoex.io/route-service/v2/widget/getdodoroute",{params:i})).data.data;if((null==e?void 0:e.resAmount)?(y(un.Success),C(e.resAmount),D(e.priceImpact),P(e.resPricePerFromToken),j(e.resPricePerToToken),k(e.baseFeeAmount),S(e.additionalFeeAmount),U(e.to),W(e.data),O(e.value),z(e.useSource),G(e.duration)):y(un.Failed),!r||!s)return;const t=yield Ht({from:r,to:e.to,value:e.value,data:e.data},s);t&&N(t)}catch(e){y(un.Failed),console.error(e)}}))),[g,r,c,e,p,d,m,t,s,n,o,h,f]);sn({refetch:Y});const q=E((()=>{const e=f?o:n;return b!==un.Loading&&e?v:null}),[b,f,o,n,v]),X=function(){const{chainId:e,account:t}=V(),n=Xt();return w((({to:e,data:o,useSource:i,duration:r,ddl:a,gasLimit:s,subtitle:l,value:c})=>{const d=60*a,u=c;i&&"weth"!==i.toLowerCase()&&s&&s.lt(3e4)&&console.debug("Warning: GasLimit less than the minimum!");const p={from:t,to:e,data:o,value:u,route:i,duration:r,ddlSecRel:d,gasLimit:s};n.execute(se._("Swap"),Object.assign({opcode:$t.TX},p),l)}),[t,e])}(),Z=w((e=>{t&&(f?v:n)&&X({to:M,data:H,useSource:$,duration:K,ddl:u,value:A,subtitle:e})}),[M,u,H,K,$,t,n,_,v,A,f]);return{status:b,refetch:Y,priceImpact:L,executeSwap:Z,baseFeeAmount:T,resAmount:q,additionalFeeAmount:R,resPricePerToToken:F,resPricePerFromToken:B}}!function(e){e.Initial="Initial",e.Loading="Loading",e.Failed="Failed",e.Success="Success"}(un||(un={}));function mn(e){pt(e),Ze(),Qe();const{provider:t,connector:n}=V();C((()=>{const t=e.defaultChainId||1;(null==n?void 0:n.connectEagerly)?n.connectEagerly(t):n.activate(t)}),[n]),C((()=>{const e=null==t?void 0:t.provider;e&&e.once&&e.once("chainChanged",(()=>{setTimeout((()=>{window.location.reload()}),200||100)}))}),[t]);const o=e.width||375,i=e.height||494;return an(Object.assign(Object.assign({},e),{width:o,height:i})),re(a,{sx:{width:o,height:i,overflow:"hidden",position:"relative",display:"flex",flexDirection:"column",minWidth:335,minHeight:494,borderRadius:16,backgroundColor:"background.paper"},className:"dodo-widget-container",children:re(on,{...e,children:e.children})})}function hn(e){const t=m({mode:e.colorMode,theme:e.theme,lang:e.locale||"en-US"}),n=E((()=>e.defaultChainId||1),[e.defaultChainId]),o=dt({provider:e.provider,jsonRpcUrlMap:e.jsonRpcUrlMap,defaultChainId:n}),i=`${o.length}+${e.jsonRpcUrlMap?Object.entries(e.jsonRpcUrlMap):""}+${e.defaultChainId}+${n}`;return re(R,{store:Me,children:re(Bt,{locale:e.locale,children:re(h,{theme:t,children:ie(K,{connectors:o,children:[re(f,{container:".dodo-widget-container"}),re(mn,{...e})]},i)})})})}function fn(e){const{width:t}=I(It),n=E((()=>{let e="";return"number"==typeof t?e=`${t}px`:t&&(e=t),e?`calc(${e} - 40px)`:"auto"}),[t]);return re(g,{container:document.querySelector(".dodo-widget-container"),maxWidth:n,...e})}function gn({onClick:e}){const t=s();return re(p,{sx:{width:"100%",position:"relative"},onClick:e,children:re(a,{component:l,sx:{width:36,height:36,borderRadius:"50%",backgroundColor:t.palette.background.input,border:`4px solid ${t.palette.background.paper}`,display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%) rotate(-90deg)"},children:re(a,{component:B,sx:{width:18,color:"text.secondary"}})})})}function bn({open:t,execute:o,onClose:i,toToken:r,fromToken:c,fromAmount:d,toAmount:p,priceImpact:m,clearFromAmt:h,clearToAmt:f,baseFeeAmount:g,curToFiatPrice:b,curFromFiatPrice:y,pricePerFromToken:v,additionalFeeAmount:w}){var A,O;const T=s(),R=I(cn),L=k(),{contractStatus:D}=I(It),_=E((()=>new n(m).gt(15)),[m]),[N,B]=x(!1),[M,U]=x(!1);return C((()=>{D!==Be.Pending&&i(),D===Be.TxSuccess&&(f(),h())}),[D]),C((()=>{B(!1)}),[b]),re(kt,{open:t,onClose:()=>{L(Kt({contractStatus:Be.Initial})),i()},title:re(e,{id:"Swap summary"}),children:ie(a,{sx:{margin:20,display:"flex",height:"100%",flexDirection:"column",borderTop:`1px solid ${T.palette.border.main}`},children:[ie(a,{sx:{py:20,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexDirection:"column",borderBottom:`1px solid ${T.palette.border.main}`},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[ie(a,{children:[ie(a,{sx:{display:"flex"},children:[re(Ct,{width:16,height:16,address:null!==(A=null==c?void 0:c.address)&&void 0!==A?A:"",marginRight:6}),re(a,{children:`${ge({input:d,decimals:null==c?void 0:c.decimals})} ${null==c?void 0:c.symbol}`})]}),re(a,{sx:{mt:4,typography:"h6",color:T.palette.text.secondary},children:y?`$${fe({input:y,showDecimals:1})}`:"-"})]}),re(a,{sx:{width:16,mx:16},component:P}),ie(a,{children:[ie(a,{sx:{display:"flex"},children:[re(Ct,{width:16,height:16,marginRight:6,address:null!==(O=null==r?void 0:r.address)&&void 0!==O?O:""}),re(a,{children:`${ge({input:p,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`})]}),re(a,{sx:{typography:"h6",mt:4,color:T.palette.text.secondary},children:b?`$${fe({input:b,showDecimals:1})}(${m}%)`:"-"})]})]}),re(a,{sx:{mt:12,typography:"h6"},children:`1 ${null==c?void 0:c.symbol} = ${ge({input:new n(p).dividedBy(new n(d)),decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`})]}),ie(a,{sx:{py:15,typography:"body2",borderBottom:`1px solid ${T.palette.border.main}`},children:[ie(a,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",color:T.palette.text.secondary},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(a,{sx:{width:16,mr:7},component:F}),re(e,{id:"Swap Detail"})]}),re(a,{component:l,children:re(a,{onClick:()=>U(!M),sx:{width:10,color:"text.secondary",transform:M?"rotateX(0deg)":"rotateX(180deg)"},component:S})})]}),ie(a,{sx:{mt:16,display:M?"initial":"none"},children:[ie(a,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(e,{id:"Basic Fee"}),re(fn,{title:re(e,{id:"Estimated service provider fees"}),ml:5})]}),re(a,{children:`${ge({input:g,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`})]}),ie(a,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(e,{id:"Additional Fee"}),re(fn,{title:re(e,{id:"Additional routing fees set by the Widget user"}),ml:5})]}),re(a,{children:`${ge({input:w,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`})]}),ie(a,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(e,{id:"Price Impact"}),re(fn,{title:re(e,{id:"Due to the market condition, market price and estimated price may have a slight difference"}),ml:5})]}),re(a,{children:`${m}%`})]}),ie(a,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(e,{id:"Slippage"}),re(fn,{title:re(e,{id:"High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:5})]}),re(a,{children:R})]})]})]}),re(a,{sx:{flex:1}}),_&&ie(a,{sx:{mb:14,display:"flex",cursor:"pointer",justifyContent:"center",alignItems:"center",typography:"h6"},onClick:()=>B(!N),children:[re(a,{sx:{mr:4,width:18,height:18,alignItems:"center"},children:re(a,N?{sx:{width:"100%",height:"100%",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"secondary.main"},children:re(a,{component:j,sx:{width:14,color:"#1a1a1b"}})}:{sx:{width:"100%",height:"100%",borderRadius:4,border:`1px solid ${T.palette.text.secondary}`}})}),re(a,{children:re(e,{components:{0:re(a,{component:"span",sx:{color:"error.main"}})},values:{priceImpact:m},id:"Price impact reaches <0>{priceImpact}</0>%, accept the quote"})})]}),re(u,{isLoading:D==Be.Pending,disabled:_&&!N,fullWidth:!0,onClick:()=>{o(),L(Kt({contractStatus:Be.Pending}))},children:D==Be.Pending?re(e,{id:"Confirming"}):re(e,{id:"Confirm swap"})})]})})}function yn(e){var{sx:t,maxVal:n,decimals:i=2,onInputChange:r}=e,a=Ie(e,["sx","maxVal","decimals","onInputChange"]);return s(),re(c,{...a,onChange:e=>{const t=0===e.target.value.length?null:ve(e.target.value,i),a=n&&t&&new o(t).gt(n)?n.toString():t;console.log("finalVal:",a),r&&r(a)}})}function vn({open:t,onClose:n}){const o=s(),i=k(),r=I(cn),l=I(dn),c=E((()=>Number(r)>=50),[r]);return re(kt,{open:t,onClose:n,title:re(e,{id:"Settings"}),children:ie(a,{sx:{mx:20},children:[ie(a,{sx:{py:20,borderTop:`1px solid ${o.palette.border.main}`},children:[ie(a,{sx:{mb:16,display:"flex",alignItems:"center"},children:[re(e,{id:"Slippage Tolerance"}),re(fn,{title:re(e,{id:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:7})]}),ie(a,{sx:{display:"flex",flexDirection:"column"},children:[re(yn,{fullWidth:!0,maxVal:100,value:r,placeholder:3..toString(),onInputChange:e=>{i((e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_SLIPPAGE",payload:e})})))(e))},suffix:re(a,{sx:{color:"text.disabled"},children:"%"}),height:36}),c&&re(a,{sx:{typography:"h6",mt:6,color:"error.main"},children:re(e,{id:"Maximum slippage do not exceed 50%"})})]})]}),ie(a,{sx:{py:20,borderTop:`1px solid ${o.palette.border.main}`},children:[ie(a,{sx:{mb:16,display:"flex",alignItems:"center"},children:[re(e,{id:"Transaction Deadline"}),re(fn,{title:re(e,{id:"If your transaction time exceeds the deadline, your transaction will be rescinded."}),ml:7})]}),re(yn,{value:l,fullWidth:!0,height:36,placeholder:se._("{DEFAULT_SWAP_DDL} minutes",{DEFAULT_SWAP_DDL:20}),onInputChange:e=>{i((e=>t=>Re(void 0,void 0,void 0,(function*(){t({type:"SET_TRANSACTION_DDL",payload:e})})))(e?Math.max(Number(e),1):""))}})]})]})})}function xn({toToken:t,fromToken:n,priceStatus:o,pricePerToToken:i,pricePerFromToken:r}){const[s,c]=x("-"),[d,u]=x(null),[p,m]=x("-"),[h,f]=x(null);C((()=>{c(null==n?void 0:n.symbol),m(null==t?void 0:t.symbol),u(i),f(r)}),[n,t,i,r]);const g=w((()=>{c(p),m(s),u(h),f(d)}),[s,d,p,h]);return re(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:{[un.Initial]:"-",[un.Loading]:ie(ae,{children:[re(b,{sx:{mr:5}}),re(e,{id:"Fetching best price..."})]}),[un.Failed]:ie(ae,{children:[re(a,{component:M,sx:{width:15,mr:5,color:"warning.main"}}),re(e,{id:"Quote not available"})]}),[un.Success]:ie(ae,{children:[re(a,{sx:{typography:"body2"},children:`1 ${s} = ${fe({input:h,showDecimals:4})} ${p}`}),re(a,{component:l,sx:{width:18,height:18,ml:6,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},children:re(a,{sx:{width:16,color:"text.secondary"},onClick:g,component:U})})]})}[o]})}function En({open:t,onClose:n}){const o=I(Ue);return re(kt,{title:re(e,{id:"Connect to your wallet"}),open:t,onClose:n,children:re(a,{sx:{mx:20,pb:20,border:"1px solid transparent",borderTopColor:"border.main"},children:Object.values(lt).map((t=>ie(a,{sx:{display:"flex",alignItems:"center",flexDirection:"column",mt:20,p:20,backgroundColor:"background.tag",borderRadius:12,cursor:"pointer","&:hover":{backgroundColor:"hover.default"}},onClick:()=>{!function(e,t,n){var o;const i=ct[e];if(!i)throw new Error(`Unknown wallet type: ${e}`);const[r]=i;null===(o=r.activate(t))||void 0===o||o.catch((e=>{4001!==e.code?n(e):r.connectEagerly?r.connectEagerly(t):r.activate(t)}))}(t.type,o,(e=>{console.error(e)}))},children:[re(a,{component:t.icon,sx:{width:32,height:32}}),re(a,{sx:{mt:8,typography:"caption"},children:t.name}),re(a,{sx:{mt:4,typography:"body2",color:"text.secondary"},children:re(e,{id:"Connect to your {0} Wallet",values:{0:t.name}})})]},t.type)))})})}function wn(){const{connector:t}=V(),[n,o]=x(!1);return ie(ae,{children:[re(u,{size:u.Size.big,fullWidth:!0,onClick:()=>{t.deactivate?t.deactivate():t.resetState(),o(!0)},"data-testid":"connect-wallet-btn",children:re(e,{id:"Connect to a wallet"})}),re(En,{open:n,onClose:()=>o(!1)})]})}var Cn;!function(e){e.Loading="Loading",e.Insufficient="ApprovalInsufficient",e.Approving="Approving",e.Sufficient="Sufficient",e.Unchecked="Unchecked"}(Cn||(Cn={}));const An=({account:e,chainId:t,offset:o,contractAddress:i})=>{var r;const a=I(Ue),s=E((()=>{var e;return ze[null!==(e=t)&&void 0!==e?e:a]}),[t]),{isETH:l}=E((()=>Ee(t)),[t]),{DODO_APPROVE:c}=s||{},d=null!==(r=null!=i?i:c)&&void 0!==r?r:null,u=function(e){const{account:t}=V(),o=I(Ue),i=I(ht),r=E((()=>Oe[o]),[o]),a=w((o=>{var a;if(!t||!e)return null;if(o.symbol===r.symbol&&xe(o.address,r.address))return new n(zt);const s=null===(a=null==i?void 0:i[o.address.toLowerCase()])||void 0===a?void 0:a.tokenAllowances;return null!=s?s:null}),[t,e,r.symbol,r.address,i]);return a}(d),p=vt(),{runningRequests:m}=Yt(),h=I(yt),f=E((()=>{var e;return null===(e=Oe[null!=t?t:a])||void 0===e?void 0:e.address}),[t]),g=w(((t,i,r)=>{if(!t)return Cn.Loading;const a=!!(null==m?void 0:m.find((e=>e.spec.opcode===$t.Approval&&e.spec.token.address===(null==t?void 0:t.address)))),s=null!=r?r:t?p(t):null,l=t?u(t):null,c=new n(null!=i?i:0);if(!e)return Cn.Unchecked;if(!s||c.minus(null!=o?o:0).gt(s))return Cn.Unchecked;if(c.isZero())return Cn.Unchecked;return t.address===f?Cn.Sufficient:a?Cn.Approving:l&&c.minus(null!=o?o:0).gt(l)?Cn.Insufficient:Cn.Sufficient}),[p,u,e,o,d,t,h,m,f]),b=w((e=>{const t=e?u(e):null;return("USDT"===(null==e?void 0:e.symbol)||(null==e?void 0:e.address.toLowerCase())==="0x6426e6017968377529487E0ef0aA4E7759724e05".toLowerCase())&&null!==t&&t.gt(0)}),[u]),y=Xt(),v=k(),x=w(((t,o)=>Re(void 0,void 0,void 0,(function*(){if(!d||!e||!t)return;const i=(e=>{let t=e.symbol;return t.indexOf("DLP_")>-1&&(t=t.replace("DLP_","")),t.indexOf("DLP")>-1&&(t=t.replace("DLP","LP")),t})(t),r=o?new n(0):void 0,a=o?se._("Reset"):se._("Approve");var s;(yield y.execute(`${a} ${i}`,{opcode:$t.Approval,token:t,contract:d,amt:r}))===Ft.Success&&v((s=null!=r?r:zt,e=>Re(void 0,void 0,void 0,(function*(){e({type:"SET_ACCOUNT_ALLOWANCES",payload:s})}))))}))),[d,e,t,y,v]),C=w((e=>{const t=new n(0);if(!e)return t.toNumber();const o=p(e);if(!o)return t.toNumber();let i=o;const r=l?.1:.02;return f===(null==e?void 0:e.address)&&(i=o.gt(r)?o.minus(r):t),i.toNumber()}),[t,p,l]);return{getApprovalState:g,getPendingRest:b,getMaxBalance:C,submitApprove:x}};function On(){var t,o;const i=s(),{isInflight:c}=Yt(),{chainId:d,account:p}=V(),m=k(),{isReverseRouting:h}=I(It),f=I(Ue),g=I(bt),y=I(gt),{isETH:v}=E((()=>Ee(d)),[d]),A=E((()=>{var e;return null===(e=Oe[null!=d?d:f])||void 0===e?void 0:e.address}),[d]),[O,T]=x(""),[R,S]=x(""),[L,D]=x(""),[_,N]=x(""),B=E((()=>r((e=>D(e)),1e3)),[]),F=E((()=>r((e=>N(e)),1e3)),[]),[j,U]=x(null),[$,z]=x(null),[K,G]=x(!1),[Y,q]=x(!1),{toFiatPrice:X,fromFiatPrice:Z}=ln({chainId:d,toToken:$,fromToken:j}),Q=vt(),J=E((()=>j?Q(j):null),[j,Q]);E((()=>$?Q($):null),[$,Q]);const{getApprovalState:ee,submitApprove:te,getPendingRest:ne,getMaxBalance:oe}=An({account:p,chainId:d}),se=E((()=>ne(h?$:j)),[null==j?void 0:j.address,null==$?void 0:$.address,ne,h]),{marginAmount:le}=rn({token:h?$:j,fiatPrice:h?X:Z}),{resAmount:ce,priceImpact:de,executeSwap:ue,baseFeeAmount:pe,additionalFeeAmount:me,resPricePerToToken:he,resPricePerFromToken:be,status:ye}=pn({toToken:$,fromToken:j,marginAmount:le,fromAmount:L,toAmount:_}),ve=w((e=>{const t=e.toString();T(t),B(t)}),[T,B]),xe=w((e=>{const t=e.toString();S(t),F(t)}),[S,F]);C((()=>{d&&(z(null),U(null),h?xe(""):ve("")),y&&y.chainId===d&&(U(y),y.amount&&(m(Kt({isReverseRouting:!1})),ve(y.amount))),g&&g.chainId===d&&(z(g),g.amount&&y&&!y.amount&&(m(Kt({isReverseRouting:!0})),xe(g.amount)))}),[g,y,d,ve,xe]);const Ce=w((()=>{ve(""),xe(""),U($),z(j)}),[U,$,z,j,ve,xe]),Ae=w((e=>h?xe(oe($)):ve(oe(j))),[ve,xe,oe,j,$,h]),Te=E((()=>(100*Number(de)).toFixed(2)),[de]),ke=E((()=>{const e=h?ce:L;return e&&Z?new n(Z).multipliedBy(e):null}),[Z,L,h,ce]),Ie=E((()=>{const e=h?_:ce;return e&&X?new n(X).multipliedBy(e):null}),[X,_,h,ce]),Re=E((()=>ie(a,{sx:{display:"flex",fontWeight:600,typography:"body2",alignItems:"center",justifyContent:"center"},children:[re(fn,{title:re(e,{id:"Due to the market condition, market price and estimated price may have a slight difference"}),mr:8}),ie(a,{sx:{display:"flex"},children:[re(e,{id:"Current price impact"}),ie(a,{sx:{color:i.palette.error.main,ml:4},children:[Te,"%"]})]})]})),[Te]),Se=E((()=>re(xn,{toToken:$,fromToken:j,priceStatus:ye,pricePerToToken:he,pricePerFromToken:be})),[$,j,ye,he,be]),Le=E((()=>!we[d||1]),[d]),De=E((()=>ye===un.Loading?re(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:ie(ae,{children:[re(b,{sx:{mr:5}}),re(e,{id:"Fetching best price..."})]})}):Le?ie(ae,{children:[re(a,{component:M,sx:{mr:6,width:16,color:"warning.main"}}),re(e,{id:"Unsupported network - switch to trade"})]}):O&&new n(Te).gt(15)?Re:Se),[ye,Se,O,Re,Te,Le]),_e=E((()=>h?new n(R).gt(0)?ge({input:ce,decimals:null==j?void 0:j.decimals}):"-":O),[O,R,ce,j,h]),Ne=E((()=>h?R:new n(O).gt(0)?ge({input:ce,decimals:null==$?void 0:$.decimals}):"-"),[O,R,ce,$,h]),Be=E((()=>{const t=ee(j,L),o=t===Cn.Approving,i=t===Cn.Insufficient&&!se,r=v?.1:.02,a=A===(null==j?void 0:j.address),s=new n(J||0);return p?c?re(u,{fullWidth:!0,isLoading:!0,disabled:!0,children:re(e,{id:"Transaction Pending"})}):j&&$?i?re(u,{fullWidth:!0,disabled:o,onClick:()=>te(j),children:re(e,o?{id:"Approving"}:{id:"Approve"})}):new n(h?_:L).gt(0)?ye===un.Loading?re(u,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-fetch-price-btn",children:re(e,{id:"Fetching Price..."})}):ce?s.lt(h?ce:L)||a&&s.lte(r)?re(u,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-insufficient-balance-btn",children:re(e,{id:"Insufficient balance"})}):re(u,{fullWidth:!0,onClick:()=>G(!0),"data-testid":"swap-review-btn",children:re(e,{id:"Review Swap"})}):re(u,{fullWidth:!0,disabled:!0,children:re(e,{id:"Quote not available"})}):re(u,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-enter-amount-btn",children:re(e,{id:"Enter an amount"})}):re(u,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-select-token-btn",children:re(e,{id:"Select Tokens"})}):re(wn,{})}),[v,p,_,L,$,ce,j,c,ue,se,te,ye,J,ee,A,h]),Pe=E((()=>j&&$?ie(a,{sx:{display:"flex",alignItems:"center"},children:[re(Ct,{token:j,sx:{width:16,height:16,mr:6}}),`${ge({input:h?ce:L,decimals:null==j?void 0:j.decimals})} ${j.symbol}`,re(a,{component:P,sx:{width:12,height:12,mx:16}}),re(Ct,{token:$,sx:{width:16,height:16,mr:6}}),`${ge({input:h?_:ce,decimals:null==$?void 0:$.decimals})} ${$.symbol}`]}):re(a,{})),[j,$,L,_,ce,h]);return ie(ae,{children:[ie(a,{sx:{display:"flex",justifyContent:"space-between",typography:"caption",margin:20},children:[re(e,{id:"Swap"}),re(a,{component:l,children:re(a,{component:H,onClick:()=>q(!0),sx:{width:19,height:19,color:"text.primary",cursor:"pointer"}})})]}),ie(a,{sx:{flex:1,padding:"0 20px 20px",overflowY:"auto"},children:[ie(a,{children:[re(_t,{sx:{mb:4},token:j,amt:_e,onMaxClick:Ae,onInputChange:ve,onInputFocus:()=>{h&&ve(""),m(Kt({isReverseRouting:!1}))},showMaxBtn:!h&&!O,occupiedAddrs:[null!==(t=null==$?void 0:$.address)&&void 0!==t?t:""],fiatPriceTxt:ke?`$${fe({input:ke,showDecimals:1})}`:"-",onTokenChange:(e,t)=>{if(t)return Ce();ve(""),xe(""),U(e)},readOnly:h}),re(gn,{onClick:Ce}),re(_t,{token:$,amt:Ne,onInputChange:xe,onInputFocus:()=>{h||xe(""),m(Kt({isReverseRouting:!0}))},occupiedAddrs:[null!==(o=null==j?void 0:j.address)&&void 0!==o?o:""],fiatPriceTxt:Ie?`$${fe({input:Ie,showDecimals:1})}(${Te}%)`:"-",onTokenChange:(e,t)=>{if(t)return Ce();ve(""),xe(""),z(e)},readOnly:!h}),re(a,{sx:{py:12,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexWrap:"wrap"},children:De})]}),Be,ie(a,{sx:{mt:13,display:"flex",typography:"h6",cursor:"pointer",justifyContent:"center",alignItems:"center",color:i.palette.text.disabled},onClick:()=>window.open("https://app.dodoex.io"),children:[re(a,{sx:{width:24,typography:"body2",transform:"translate(1px, 2px)","& path":{fill:i.palette.text.disabled}},component:W}),re(e,{id:"Powered by DODO protocol"})]})]}),re(bn,{toToken:$,fromToken:j,fromAmount:h?ce:L,toAmount:h?_:ce,open:K,baseFeeAmount:pe,priceImpact:Te,additionalFeeAmount:me,curToFiatPrice:Ie,execute:()=>ue(Pe),clearFromAmt:()=>ve(""),clearToAmt:()=>xe(""),curFromFiatPrice:ke,pricePerFromToken:be,onClose:()=>G(!1)}),re(vn,{open:Y,onClose:()=>q(!1)})]})}function Tn(e){return re(hn,{...e,children:re(On,{})})}function kn(e){const t=document.getElementById("dodo-swap-widget");he(t).render(re(hn,{...e,children:re(On,{})}))}export{kn as InitSwapWidget,Tn as SwapWidget};
|
package/dist/locales/en-US.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*eslint-disable*/
|
|
2
2
|
|
|
3
|
-
var enUS={messages:{"Additional Fee":"Additional Fee","Additional routing fees set by the Widget user":"Additional routing fees set by the Widget user","Approve":"Approve","Approving":"Approving","Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote.":"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote.","Balance:":"Balance:","Basic Fee":"Basic Fee","Close":"Close","Confirm swap":"Confirm swap","Confirming":"Confirming","Connect to a wallet":"Connect to a wallet","Connect to your wallet":"Connect to your wallet","Connect to your {0} Wallet":["Connect to your ",["0"]," Wallet"],"Current price impact":"Current price impact","Dismiss":"Dismiss","Due to the market condition, market price and estimated price may have a slight difference":"Due to the market condition, market price and estimated price may have a slight difference","Enter an amount":"Enter an amount","Enter the token symbol or address":"Enter the token symbol or address","Estimated service provider fees":"Estimated service provider fees","Fetching Price...":"Fetching Price...","Fetching best price...":"Fetching best price...","ForceStop exception":"ForceStop exception","Gas price is too low, please adjust in your wallet and try again":"Gas price is too low, please adjust in your wallet and try again","High slippage tolerance will increase the success rate of transaction, but might not get the best quote.":"High slippage tolerance will increase the success rate of transaction, but might not get the best quote.","If your transaction time exceeds the deadline, your transaction will be rescinded.":"If your transaction time exceeds the deadline, your transaction will be rescinded.","Insufficient balance":"Insufficient balance","Insufficient funds - Please retry after depositing more {EtherTokenSymbol} into your wallet":["Insufficient funds - Please retry after depositing more ",["EtherTokenSymbol"]," into your wallet"],"Max":"Max","Maximum slippage do not exceed 50%":"Maximum slippage do not exceed 50%","No ForceStop access":"No ForceStop access","Powered by DODO protocol":"Powered by DODO protocol","Price Impact":"Price Impact","Price impact exceeds the slippage tolerance you set. Try increasing the slippage tolerance.":"Price impact exceeds the slippage tolerance you set. Try increasing the slippage tolerance.","Price impact reaches <0>{priceImpact}</0>%, accept the quote":["Price impact reaches <0>",["priceImpact"],"</0>%, accept the quote"],"Quote not available":"Quote not available","RPC node data exception":"RPC node data exception","Reset":"Reset","Review Swap":"Review Swap","SELECT TOKEN":"SELECT TOKEN","SafeERC20: low-level call failed. Please log a Zendesk support ticket or contact the DODO team.":"SafeERC20: low-level call failed. Please log a Zendesk support ticket or contact the DODO team.","Select Tokens":"Select Tokens","Select a token":"Select a token","Service update, please wait and try again":"Service update, please wait and try again","Settings":"Settings","Slippage":"Slippage","Slippage Tolerance":"Slippage Tolerance","Something went wrong.":"Something went wrong.","Swap":"Swap","Swap Detail":"Swap Detail","Swap summary":"Swap summary","This CP has been settled by other addrs":"This CP has been settled by other addrs","Transaction Deadline":"Transaction Deadline","Transaction Pending":"Transaction Pending","Transaction Time:":"Transaction Time:","Transaction rejected.":"Transaction rejected.","Unable to SETTLE during the cooling-off period":"Unable to SETTLE during the cooling-off period","Unsupported network - switch to trade":"Unsupported network - switch to trade","User denied transaction signature.":"User denied transaction signature.","View on Etherscan":"View on Etherscan","Wallet incompatibility":"Wallet incompatibility","{0} confirmed":[["0"]," confirmed"],"{0} pending":[["0"]," pending"],"{DEFAULT_SWAP_DDL} minutes":[["DEFAULT_SWAP_DDL"]," minutes"]}};
|
|
3
|
+
var enUS={messages:{"Additional Fee":"Additional Fee","Additional routing fees set by the Widget user":"Additional routing fees set by the Widget user","Approve":"Approve","Approving":"Approving","Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote.":"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote.","Balance:":"Balance:","Basic Fee":"Basic Fee","Close":"Close","Confirm swap":"Confirm swap","Confirming":"Confirming","Connect to a wallet":"Connect to a wallet","Connect to your wallet":"Connect to your wallet","Connect to your {0} Wallet":["Connect to your ",["0"]," Wallet"],"Current price impact":"Current price impact","Dismiss":"Dismiss","Due to the market condition, market price and estimated price may have a slight difference":"Due to the market condition, market price and estimated price may have a slight difference","Enter an amount":"Enter an amount","Enter the token symbol or address":"Enter the token symbol or address","Estimated service provider fees":"Estimated service provider fees","Fetching Price...":"Fetching Price...","Fetching best price...":"Fetching best price...","ForceStop exception":"ForceStop exception","Gas price is too low, please adjust in your wallet and try again":"Gas price is too low, please adjust in your wallet and try again","High slippage tolerance will increase the success rate of transaction, but might not get the best quote.":"High slippage tolerance will increase the success rate of transaction, but might not get the best quote.","If your transaction time exceeds the deadline, your transaction will be rescinded.":"If your transaction time exceeds the deadline, your transaction will be rescinded.","Insufficient balance":"Insufficient balance","Insufficient funds - Please retry after depositing more {EtherTokenSymbol} into your wallet":["Insufficient funds - Please retry after depositing more ",["EtherTokenSymbol"]," into your wallet"],"Max":"Max","Maximum slippage do not exceed 50%":"Maximum slippage do not exceed 50%","No ForceStop access":"No ForceStop access","Powered by DODO protocol":"Powered by DODO protocol","Price Impact":"Price Impact","Price impact exceeds the slippage tolerance you set. Try increasing the slippage tolerance.":"Price impact exceeds the slippage tolerance you set. Try increasing the slippage tolerance.","Price impact reaches <0>{priceImpact}</0>%, accept the quote":["Price impact reaches <0>",["priceImpact"],"</0>%, accept the quote"],"Quote not available":"Quote not available","RPC node data exception":"RPC node data exception","Reset":"Reset","Review Swap":"Review Swap","SELECT TOKEN":"SELECT TOKEN","SafeERC20: low-level call failed. Please log a Zendesk support ticket or contact the DODO team.":"SafeERC20: low-level call failed. Please log a Zendesk support ticket or contact the DODO team.","Select Tokens":"Select Tokens","Select a token":"Select a token","Service update, please wait and try again":"Service update, please wait and try again","Settings":"Settings","Slippage":"Slippage","Slippage Tolerance":"Slippage Tolerance","Something went wrong.":"Something went wrong.","Swap":"Swap","Swap Detail":"Swap Detail","Swap summary":"Swap summary","This CP has been settled by other addrs":"This CP has been settled by other addrs","Transaction Deadline":"Transaction Deadline","Transaction Pending":"Transaction Pending","Transaction Time:":"Transaction Time:","Transaction rejected.":"Transaction rejected.","Tx":"Tx","Unable to SETTLE during the cooling-off period":"Unable to SETTLE during the cooling-off period","Unsupported network - switch to trade":"Unsupported network - switch to trade","User denied transaction signature.":"User denied transaction signature.","View on Etherscan":"View on Etherscan","Wallet incompatibility":"Wallet incompatibility","{0} confirmed":[["0"]," confirmed"],"{0} pending":[["0"]," pending"],"{DEFAULT_SWAP_DDL} minutes":[["DEFAULT_SWAP_DDL"]," minutes"]}};
|
|
4
4
|
|
|
5
5
|
export { enUS as default };
|
|
@@ -5,16 +5,17 @@ export interface ReviewDialogProps {
|
|
|
5
5
|
open: boolean;
|
|
6
6
|
execute: () => void;
|
|
7
7
|
onClose: () => void;
|
|
8
|
+
clearToAmt: () => void;
|
|
8
9
|
clearFromAmt: () => void;
|
|
9
10
|
toToken: TokenInfo | null;
|
|
10
11
|
fromToken: TokenInfo | null;
|
|
11
12
|
priceImpact: string;
|
|
12
|
-
fromAmount: string;
|
|
13
|
-
toAmount: number | null;
|
|
13
|
+
fromAmount: string | number | null;
|
|
14
|
+
toAmount: string | number | null;
|
|
14
15
|
baseFeeAmount: number | null;
|
|
15
16
|
additionalFeeAmount: number | null;
|
|
16
17
|
curToFiatPrice: BigNumber | null;
|
|
17
18
|
curFromFiatPrice: BigNumber | null;
|
|
18
19
|
pricePerFromToken: number | null;
|
|
19
20
|
}
|
|
20
|
-
export declare function ReviewDialog({ open, execute, onClose, toToken, fromToken, fromAmount, toAmount, priceImpact, clearFromAmt, baseFeeAmount, curToFiatPrice, curFromFiatPrice, pricePerFromToken, additionalFeeAmount, }: ReviewDialogProps): JSX.Element;
|
|
21
|
+
export declare function ReviewDialog({ open, execute, onClose, toToken, fromToken, fromAmount, toAmount, priceImpact, clearFromAmt, clearToAmt, baseFeeAmount, curToFiatPrice, curFromFiatPrice, pricePerFromToken, additionalFeeAmount, }: ReviewDialogProps): JSX.Element;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BoxProps } from '@dodoex/components';
|
|
3
|
-
export declare function NumberInput({ readOnly, sx, value, decimals, onChange, suffix, withClear, placeholder, }: {
|
|
3
|
+
export declare function NumberInput({ readOnly, sx, value, decimals, onChange, suffix, withClear, onFocus, placeholder, }: {
|
|
4
4
|
readOnly?: boolean;
|
|
5
5
|
sx?: BoxProps['sx'];
|
|
6
6
|
value?: string;
|
|
7
7
|
decimals?: number;
|
|
8
|
+
onFocus?: () => void;
|
|
8
9
|
onChange?: (v: string) => void;
|
|
9
10
|
suffix?: React.ReactNode | string;
|
|
10
11
|
withClear?: boolean;
|
|
@@ -11,6 +11,8 @@ export interface TokenCardProps {
|
|
|
11
11
|
onMaxClick?: (max: string) => void;
|
|
12
12
|
token?: TokenPickerProps['value'];
|
|
13
13
|
onInputChange?: (v: string) => void;
|
|
14
|
+
onInputFocus?: () => void;
|
|
15
|
+
onTokenClick?: () => void;
|
|
14
16
|
onTokenChange: TokenPickerProps['onChange'];
|
|
15
17
|
}
|
|
16
|
-
export declare function TokenCard({ sx, amt, token, readOnly, showMaxBtn, onMaxClick, fiatPriceTxt, occupiedAddrs, onInputChange, onTokenChange, }: TokenCardProps): JSX.Element;
|
|
18
|
+
export declare function TokenCard({ sx, amt, token, readOnly, showMaxBtn, onMaxClick, fiatPriceTxt, occupiedAddrs, onInputFocus, onTokenClick, onInputChange, onTokenChange, }: TokenCardProps): JSX.Element;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { BigNumber as EthersBigNumber } from '@ethersproject/bignumber';
|
|
2
|
-
import BigNumber from 'bignumber.js';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
export default function useExecuteSwap(): ({
|
|
5
|
-
|
|
6
|
-
parsedFromAmt: BigNumber;
|
|
3
|
+
export default function useExecuteSwap(): ({ to, data, useSource, duration, ddl, gasLimit, subtitle, value, }: {
|
|
4
|
+
value: string;
|
|
7
5
|
to: string;
|
|
8
6
|
data: string;
|
|
9
7
|
useSource?: string | undefined;
|
|
@@ -9,10 +9,11 @@ export declare enum RoutePriceStatus {
|
|
|
9
9
|
export interface FetchRoutePrice {
|
|
10
10
|
fromToken: TokenInfo | null;
|
|
11
11
|
toToken: TokenInfo | null;
|
|
12
|
-
marginAmount
|
|
12
|
+
marginAmount?: string;
|
|
13
13
|
fromAmount: string;
|
|
14
|
+
toAmount: string;
|
|
14
15
|
}
|
|
15
|
-
export declare function useFetchRoutePrice({ toToken, fromToken, fromAmount, marginAmount, }: FetchRoutePrice): {
|
|
16
|
+
export declare function useFetchRoutePrice({ toToken, fromToken, fromAmount, toAmount, marginAmount, }: FetchRoutePrice): {
|
|
16
17
|
status: RoutePriceStatus;
|
|
17
18
|
refetch: () => Promise<void>;
|
|
18
19
|
priceImpact: number | null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TokenInfo } from '../Token';
|
|
2
2
|
export interface MarginAmountProps {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
token: TokenInfo | null;
|
|
4
|
+
fiatPrice: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function useMarginAmount({
|
|
6
|
+
export declare function useMarginAmount({ token, fiatPrice }: MarginAmountProps): {
|
|
7
7
|
marginAmount: string;
|
|
8
8
|
};
|
|
@@ -2,5 +2,5 @@ export declare const store: import("@reduxjs/toolkit").EnhancedStore<import("red
|
|
|
2
2
|
settings: import("./reducers/settings").State;
|
|
3
3
|
wallet: import("./reducers/wallet").State;
|
|
4
4
|
token: import("./reducers/token").State;
|
|
5
|
-
globals: import("
|
|
5
|
+
globals: import("./reducers/globals").State;
|
|
6
6
|
}>, import("redux").AnyAction, any>;
|