@dodoex/widgets 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@lingui/react"),t=require("bignumber.js"),n=require("lodash"),o=require("@dodoex/components"),s=require("@ethersproject/address"),a=require("react"),r=require("react-redux"),i=require("@dodoex/icons"),l=require("identicon.js"),c=require("@web3-react/core"),d=require("@reduxjs/toolkit"),u=require("redux"),p=require("@ethersproject/contracts"),m=require("@ethersproject/constants"),h=require("@ethersproject/abi"),f=require("@web3-react/eip1193"),x=require("@web3-react/walletconnect"),b=require("@web3-react/metamask"),g=require("@ethersproject/providers"),y=require("@web3-react/types"),E=require("react/jsx-runtime"),v=require("@lingui/core"),C=require("react-window"),w=require("make-plural/plurals"),j=require("axios"),T=require("@ethersproject/bignumber"),A=require("react-dom/client");function O(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function B(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var k=O(t),S=B(a),R=O(l),I=O(j);function L({input:e,showDecimals:n=4,showPrecisionDecimals:o=2,showIntegerOnly:s=!1,showDecimalsOnly:a=!1,noGroupSeparator:r=!1}){const i=new t.BigNumber(e);if(i.isNaN())return"-";let l=i.dp(n,t.BigNumber.ROUND_DOWN);return l.eq(0)&&(i.gt(0)||i.lt(0))&&(l=i.sd(null!=o?o:n,t.BigNumber.ROUND_DOWN)),s&&(l=l.integerValue(t.BigNumber.ROUND_DOWN)),a&&(l=l.minus(l.integerValue(t.BigNumber.ROUND_DOWN))),r?l.toFormat({decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0}):l.toFormat()}function D({input:e,decimals:n,showPrecisionDecimals:o=2,noGroupSeparator:s}){if(null==e)return"-";const a=new t.BigNumber(e);if(a.isNaN())return"-";return L({input:a,showDecimals:void 0===n?0:n>6?6:n>4?4:n,showPrecisionDecimals:o,noGroupSeparator:s})}function N(e){if("number"==typeof e)return N(new t.BigNumber(e));if(e.isNaN())return"NaN";if(e.isNegative())return`-${N(e.negated())}`;if(e.isZero())return"0";let n=e.integerValue(t.BigNumber.ROUND_FLOOR),o=e.minus(n),s="";for(;!n.isZero();){s=n.modulo(10).toString().toString()+s,n=n.idiv(10)}if(""===s&&(s="0"),o.isZero())return s;s+=".";let a=0;for(;!o.isZero()&&a<100;){const e=o.times(10),n=e.integerValue(t.BigNumber.ROUND_FLOOR);s+=n.toString(),o=e.minus(n),a+=1}return s}const M=(e,n)=>{if("string"==typeof e&&!e.match(/[-+]?\d+(.+d+)?/))return e;const o=new t.BigNumber(e);if(n){let e=o.toFixed(n,t.BigNumber.ROUND_DOWN);return s=e,new t.BigNumber(s).isZero()&&(e=N(o.precision(n,t.BigNumber.ROUND_DOWN))),e}var s;return N(o)},_=(e,t)=>{let n=e;const o=n.match("[0-9。.]+");n=o&&o.length>0?o[0]:"",n=n.replace("。",".");let s=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&&(s=t[1].length),n=t.join(".")}return t>=0&&s>t?M(n,t):n},P=(e,n,o)=>{const s=new t.BigNumber(e).times(new t.BigNumber(10).pow(n));return o?s:s.dp(0)},F=(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)};function U(e){try{return s.getAddress(e)}catch(e){return!1}}const W=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 H;!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"}(H||(H={}));const $={[H.MAINNET]:["https://rpc.ankr.com/eth","https://eth-mainnet.public.blastapi.io","https://eth-rpc.gateway.pokt.network","https://main-rpc.linkpool.io"],[H.RINKEBY]:["https://rinkeby-light.eth.linkpool.io/"],[H.GOERLI]:["https://goerli.optimism.io/"],[H.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"],[H.HECO]:["https://http-mainnet.hecochain.com","https://pub001.hg.network/rpc"],[H.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"],[H.ARBITRUM_ONE]:["https://arb1.arbitrum.io/rpc","https://rpc.ankr.com/arbitrum"],[H.ARBITRUM_RINKEBY]:["https://rinkeby.arbitrum.io/rpc"],[H.AURORA]:["https://mainnet.aurora.dev/"],[H.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"],[H.OKCHAIN]:["https://exchainrpc.okex.org","https://okc-mainnet.gateway.pokt.network/v1/lb/6275309bea1b320039c893ff"],[H.OPTIMISM]:["https://mainnet.optimism.io","https://optimism-mainnet.public.blastapi.io"],[H.BOBA]:["https://mainnet.boba.network","https://boba-mainnet.gateway.pokt.network/v1/lb/623ad21b20354900396fed7f","https://lightning-replica.boba.network"],[H.AVALANCHE]:["https://api.avax.network/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://ava-mainnet.public.blastapi.io/ext/bc/C/rpc"],[H.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"]},z={symbol:"ETH",address:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",name:"Ether",decimals:18,showDecimals:4,wrappedTokenSymbol:"WETH"},V={[H.MAINNET]:Object.assign(Object.assign({},z),{wrappedTokenAddress:"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}),[H.RINKEBY]:Object.assign(Object.assign({},z),{wrappedTokenAddress:"0xB26c0d8Be2960c70641A95A9195BE1f59Ac83aC0"}),[H.GOERLI]:Object.assign(Object.assign({},z),{wrappedTokenAddress:"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6"}),[H.OPTIMISM]:Object.assign(Object.assign({},z),{wrappedTokenAddress:"0x4200000000000000000000000000000000000006"}),[H.CRONOS]:Object.assign(Object.assign({},z),{symbol:"CRO",name:"Cronos",wrappedTokenSymbol:"WCRO",wrappedTokenAddress:"0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23"}),[H.BOBA]:Object.assign(Object.assign({},z),{wrappedTokenAddress:"0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000"}),[H.BSC]:Object.assign(Object.assign({},z),{symbol:"BNB",name:"BNB",wrappedTokenSymbol:"WBNB",wrappedTokenAddress:"0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"}),[H.OKCHAIN]:Object.assign(Object.assign({},z),{symbol:"OKT",name:"OKT",wrappedTokenSymbol:"WOKT",wrappedTokenAddress:"0x8F8526dbfd6E38E3D8307702cA8469Bae6C56C15"}),[H.HECO]:Object.assign(Object.assign({},z),{symbol:"HT",name:"HT",showDecimals:6,wrappedTokenSymbol:"WHT",wrappedTokenAddress:"0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f"}),[H.POLYGON]:Object.assign(Object.assign({},z),{symbol:"MATIC",name:"MATIC",showDecimals:6,wrappedTokenSymbol:"WMATIC",wrappedTokenAddress:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"}),[H.MOONRIVER]:Object.assign(Object.assign({},z),{symbol:"MOVR",name:"MOVR",showDecimals:6,wrappedTokenSymbol:"WMOVR",wrappedTokenAddress:"0x98878b06940ae243284ca214f92bb71a2b032b8a"}),[H.ARBITRUM_ONE]:Object.assign(Object.assign({},z),{name:"Ethereum",showDecimals:6,wrappedTokenAddress:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"}),[H.ARBITRUM_RINKEBY]:Object.assign(Object.assign({},z),{name:"Ether",showDecimals:6,wrappedTokenAddress:"0xEBbc3452Cc911591e4F18f3b36727Df45d6bd1f9"}),[H.AURORA]:Object.assign(Object.assign({},z),{name:"Ethereum",showDecimals:6,wrappedTokenAddress:"0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB"}),[H.AVALANCHE]:Object.assign(Object.assign({},z),{symbol:"AVAX",name:"Avalanche",showDecimals:6,wrappedTokenSymbol:"WAVAX",wrappedTokenAddress:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7"})},q={[H.MAINNET]:"ethereum",[H.RINKEBY]:"rinkeby",[H.GOERLI]:"goerli",[H.OPTIMISM]:"optimism",[H.CRONOS]:"cronos",[H.BOBA]:"boba",[H.BSC]:"bsc",[H.OKCHAIN]:"okex-chain",[H.HECO]:"heco",[H.POLYGON]:"polygon",[H.MOONRIVER]:"moonriver",[H.ARBITRUM_ONE]:"arbitrum",[H.ARBITRUM_RINKEBY]:"arb-rinkeby",[H.AURORA]:"aurora",[H.AVALANCHE]:"avalanche"},K={[H.MAINNET]:"etherscan.io",[H.RINKEBY]:"rinkeby.etherscan.io",[H.GOERLI]:"goerli.etherscan.io",[H.OPTIMISM]:"optimistic.etherscan.io",[H.CRONOS]:"cronoscan.com",[H.BOBA]:"blockexplorer.boba.network",[H.BSC]:"bscscan.com",[H.OKCHAIN]:"www.oklink.com/okexchain",[H.HECO]:"hecoinfo.com",[H.POLYGON]:"polygonscan.com",[H.MOONRIVER]:"moonriver.moonscan.io",[H.ARBITRUM_ONE]:"arbiscan.io",[H.ARBITRUM_RINKEBY]:"testnet.arbiscan.io",[H.AURORA]:"aurorascan.dev",[H.AVALANCHE]:"snowtrace.io"},G=({tokenAmount:e,tokenAddress:t,chainId:n})=>{let o=new k.default(0);const s=V[n];return t.toLowerCase()===s.address.toLowerCase()&&(o=P(e,18)),`0x${o.toString(16)}`};function Y(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 s=0;for(o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(n[o[s]]=e[o[s]])}return n}function X(e,t,n,o){return new(n||(n=Promise))((function(s,a){function r(e){try{l(o.next(e))}catch(e){a(e)}}function i(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,i)}l((o=o.apply(e,t||[])).next())}))}const Z={colorMode:"dark",slippage:3..toString(),ddl:20};var Q=(e=Z,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 J={chainId:H.MAINNET,latestBlockNumber:0};var ee=(e=J,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 te={tokenList:[],popularTokenList:[],ethBalance:void 0,accountBalances:{},balanceLoadings:{},slippageWithTokens:[]};var ne=(e=te,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}};const oe={height:void 0,width:void 0,apikey:"",feeRate:0,rebateTo:""};var se=(e=oe,t)=>"SET_GLOBAL_PROPS"===t.type?Object.assign(Object.assign({},e),t.payload):e;const ae={settings:Z,wallet:J,globals:oe,token:te},re=u.combineReducers({settings:Q,wallet:ee,token:ne,globals:se}),ie=d.configureStore({reducer:re,middleware:e=>e({serializableCheck:{ignoredActions:["SET_ACCOUNT_BALANCES","SET_ETH_BALANCE"],ignoredPaths:["token.accountBalances","token.ethBalance"]}}),preloadedState:ae}),le=e=>(null!=e?e:ie.getState()).wallet.chainId,ce=e=>(null!=e?e:ie.getState()).wallet.latestBlockNumber,de=e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_ACCOUNT_BALANCES",payload:e})})),ue=e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_BALANCE_LOADINGS",payload:e})}));var pe=[{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"}],me={[H.MAINNET]:{MULTI_CALL:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",DODO_APPROVE:"0x14F7B8Fb0c1447DdE7bcf92a8d9BB058c8A5FE64",ERC20_HELPER:"0xD9ef2d1583e8Aa196123e773BE38B539a4d149df"},[H.RINKEBY]:{MULTI_CALL:"0xb7E1C577f95959a3eD11f9281702850328b4e0e4",DODO_APPROVE:"0xcC8d87A7C747eeE4242045C47Ef25e0A81D56ae3",ERC20_HELPER:"0x6A42091d713A67E25a1D11aeE14E7AEB96E0331f"},[H.GOERLI]:{MULTI_CALL:"0x696E25A5e2AEd1C55E6d6Cfa0532Bbda9020165d",DODO_APPROVE:"0xC9143e54021f4a6d33b9b89DBB9F458AaEdd56FB",ERC20_HELPER:"0x24549FC74B3076A962624A26370ed556c467F74C"},[H.BSC]:{MULTI_CALL:"0x1Ee38d535d541c55C9dae27B12edf090C608E6Fb",DODO_APPROVE:"0x7F91869b17968299Ac0e008cca8AD0E6C1b6Ed05",ERC20_HELPER:"0x566651Ad34f6306872FaC5fB95bbF4C9beE8D8F2"},[H.HECO]:{MULTI_CALL:"0x76a328B3440B9276a31523e731B34082df7a6f1A",DODO_APPROVE:"0x68b6c06Ac8Aa359868393724d25D871921E97293",ERC20_HELPER:"0x270C2abC692Dd476B860CCbDfD6D8146BF61f8D8"},[H.POLYGON]:{MULTI_CALL:"0xc9eD9B18e447e600238fe50e944B9062B664DEa4",DODO_APPROVE:"0x292E6b2e054e1157df71C1C9510265CA8C0c7672",ERC20_HELPER:"0xfd24312Ec7871A6D1a31e454D5AbB16c6c25a9b3"},[H.ARBITRUM_ONE]:{MULTI_CALL:"0xF718F2bd590E5621e53f7b89398e52f7Acced8ca",DODO_APPROVE:"0xA867241cDC8d3b0C07C85cC06F25a0cD3b5474d8",ERC20_HELPER:"0x7C062B9C584fA6eC2504270790D38240A2c5fE72"},[H.ARBITRUM_RINKEBY]:{MULTI_CALL:"0x696E25A5e2AEd1C55E6d6Cfa0532Bbda9020165d",DODO_APPROVE:"0x5BaF16d57620Cb361F622232F3cb4090e35F3da2",ERC20_HELPER:"0x5B2fd46E6E3Ff1E479d651ec0b210882Aa9871dF"},[H.AURORA]:{MULTI_CALL:"0x989DcAA95801C527C5B73AA65d3962dF9aCe1b0C",DODO_APPROVE:"0x335aC99bb3E51BDbF22025f092Ebc1Cf2c5cC619",ERC20_HELPER:"0xE8C9A78725D0451FA19878D5f8A3dC0D55FECF25"},[H.MOONRIVER]:{MULTI_CALL:"0x2ff2CeE6E9359F9eA1cF2f51d18bF9F2045447E4",DODO_APPROVE:"0xE8C9A78725D0451FA19878D5f8A3dC0D55FECF25",ERC20_HELPER:"0x6373ceB657C83C91088d328622573FB766064Ac4"},[H.OKCHAIN]:{MULTI_CALL:"0x5e84190a270333aCe5B9202a3F4ceBf11b81bB01",DODO_APPROVE:"0x7737fd30535c69545deeEa54AB8Dd590ccaEBD3c",ERC20_HELPER:"0x4775b1858f1e417C9609D455C3Ad8751ec01daC4"},[H.OPTIMISM]:{MULTI_CALL:"0xb98Ac2fEFc8b73aeAE33D02BB00c26E12afCa9Df",DODO_APPROVE:"0xa492d6eABcdc3E204676f15B950bBdD448080364",ERC20_HELPER:"0x42E456ea0dd7538ea103fBb1d0388D14C97bB5b2"},[H.BOBA]:{MULTI_CALL:"0xD56281EF996B6B29874C77D2e1464216E8043127",DODO_APPROVE:"0x8F8Dd7DB1bDA5eD3da8C9daf3bfa471c12d58486",ERC20_HELPER:"0x9FCFD9ff955D36856F8EE480471B05488C0eB5cA"},[H.AVALANCHE]:{MULTI_CALL:"0x97f0153E7F5749640aDF3Ff9CFC518b79D6Fe53b",DODO_APPROVE:"0xCFea63e3DE31De53D68780Dd65675F169439e470",ERC20_HELPER:"0xC3528D128CC227fd60793007b5e3FdF7c2945282"},[H.CRONOS]:{MULTI_CALL:"0x4f4408D78F9E9e242c17C635FbD0f1952951c917",DODO_APPROVE:"0x9B736bB8f336f61E16454DCA4dE130703D151042",ERC20_HELPER:"0xbd2F5c60cf7d60daD2106ceD4D21b90722761f14"}};function he(e,t,...n){return X(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 s=yield function(e,t,n){return X(this,void 0,void 0,(function*(){const o=yield fe(e,t,n),s=new Map;for(const{req:e,resp:t}of o)s.set(e,t);return e.map((e=>({req:e,resp:s.get(e)})))}))}(o,e,t),a=new Map;for(const{req:e,resp:t}of s)a.set(e,null==t?void 0:t.result);return n.map((e=>e.filter((e=>!e.callData||a.get(e.callData))).map(((e,t)=>e.processor(e.callData?a.get(e.callData):null,t)))))}))}function fe(e,t,o){return X(this,void 0,void 0,(function*(){let s=[e];e.length>800&&(s=n.chunk(e,800));let a=[];const r=s.map((e=>X(this,void 0,void 0,(function*(){const n=e.map((e=>[e.to,e.data])),s={data:t.interface.encodeFunctionData("aggregate",[n]),to:o};let r;try{r=yield t.provider.call(s)}catch(n){const s=e.length;if(s>20){const n=Math.floor(s/2),[r,i]=yield Promise.all([fe(e.slice(0,n),t,o),fe(e.slice(n,s),t,o)]);a=[...a,...r,...i]}else{const e="[sendCallReqs] error";console.error(e,n)}}if(void 0===r)throw new Error("Unexpected batch result");const[i,l]=h.defaultAbiCoder.decode(["uint256","bytes[]"],r);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(r)).filter((e=>"fulfilled"===e.status)).forEach((({value:e})=>{a=[...a,...e]})),a}))}function xe(e,t,n,o){if(!U(e)||e===m.AddressZero)throw Error(`Invalid 'address' parameter '${e}'.`);return new p.Contract(e,t,function(e,t){return t?function(e,t){return e.getSigner(t).connectUnchecked()}(e,t):e}(n,o))}function be(){const{provider:e,account:t,chainId:n}=c.useWeb3React(),[o,s]=a.useState(!1),r=a.useMemo((()=>me[n]),[n]),i=a.useCallback(((n,o)=>{if(e)return xe(n,o,e,t)}),[e,t]),l=a.useCallback((e=>{if(!r)return;const{MULTI_CALL:t}=r,n=i(t,pe);return(()=>X(this,void 0,void 0,(function*(){if(n){s(!0);try{const[o]=yield he(n,t,e);return o}catch(e){console.error("Contract: useMultiContract is error",e)}s(!1)}})))()}),[r,i]);return{getContract:i,contractConfig:r,call:l,loading:o}}var ge=[{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 ye(){const{provider:e,account:t}=c.useWeb3React(),n=r.useDispatch(),o=r.useSelector(ce);a.useEffect((()=>{(()=>{X(this,void 0,void 0,(function*(){if(!e||!t)return;const o=yield e.getBalance(t);n((e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_ETH_BALANCE",payload:e})})))(new k.default(o.toString()).div(1e18)))}))})()}),[e,t,n,o])}function Ee(){const{provider:e,chainId:t}=c.useWeb3React(),n=r.useDispatch();a.useEffect((()=>{const o=e=>{n((e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_BLOCK_NUMBER",payload:e})})))(e))};return(()=>{X(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 ve(e){return Number.parseInt(e,16)}class Ce extends y.Connector{constructor(e,t){super(e),this.customProvider=t,t.on("connect",(({chainId:e})=>{this.actions.update({chainId:ve(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:ve(e)})})).on("accountsChanged",(e=>{this.actions.update({accounts:e})}))}activate(){return X(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 we([e,t]){return[e,t]}var je;function Te(){return Te=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},Te.apply(this,arguments)}var Ae,Oe;function Be(){return Be=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},Be.apply(this,arguments)}var ke;!function(e){e.INTEGRATOR="integrator",e.METAMASK="metamask",e.WALLET_CONNECT="walletConnect"}(ke||(ke={}));const Se={[ke.METAMASK]:{name:"MetaMask",type:ke.METAMASK,icon:function(e){return S.createElement("svg",Te({height:355,viewBox:"0 0 397 355",width:397,xmlns:"http://www.w3.org/2000/svg"},e),je||(je=S.createElement("g",{fill:"none",fillRule:"evenodd",transform:"translate(-1 -1)"},S.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"}),S.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)"}),S.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"}),S.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"}),S.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"}),S.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),S.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),S.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"}),S.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 56.25-39.305949z",fill:"#eb8f35"}),S.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),S.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),S.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),S.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),S.createElement("path",{d:"m114.622644 327.195472 56.25-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3"}),S.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)"}),S.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)"}),S.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),S.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"}),S.createElement("g",{transform:"matrix(-1 0 0 1 399.056611 0)"},S.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"}),S.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),S.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),S.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"}),S.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 55.18868-38.243626z",fill:"#eb8f35"}),S.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),S.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),S.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),S.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),S.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)"}),S.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),S.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"},[ke.WALLET_CONNECT]:{name:"WalletConnect",type:ke.WALLET_CONNECT,icon:function(e){return S.createElement("svg",Be({height:512,viewBox:"0 0 512 512",width:512,xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),Ae||(Ae=S.createElement("radialGradient",{id:"a",cx:"0%",cy:"50%",r:"100%"},S.createElement("stop",{offset:0,stopColor:"#5d9df6"}),S.createElement("stop",{offset:1,stopColor:"#006fff"}))),Oe||(Oe=S.createElement("g",{fill:"none",fillRule:"evenodd"},S.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)"}),S.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)"}))))}}},Re={};function Ie({provider:e,jsonRpcUrlMap:t,defaultChainId:n}){const o=console.error,s=a.useMemo((()=>function(e,t){if(t){if(g.JsonRpcProvider.isProvider(t))return we(c.initializeConnector((e=>new Ce(e,t))));if(g.JsonRpcProvider.isProvider(t.provider))throw new Error("Eip1193Bridge is experimental: pass your ethers Provider directly");return we(c.initializeConnector((n=>new f.EIP1193({actions:n,provider:t,onError:e}))))}}(o,e)),[o,e]),r=a.useMemo((()=>function(e){return we(c.initializeConnector((t=>new b.MetaMask({actions:t,onError:e}))))}(o)),[o]),i=a.useMemo((()=>t?Object.assign(Object.assign({},$),t):$),[t]),l=a.useMemo((()=>function(e,t,n,o){return we(c.initializeConnector((s=>new x.WalletConnect({actions:s,options:{rpc:t,qrcode:e},onError:o,defaultChainId:n}))))}(!0,i,n,o)),[i,n,o]);return s&&(Re[ke.INTEGRATOR]=s),Re[ke.METAMASK]=r,Re[ke.WALLET_CONNECT]=l,Object.values(Re)}function Le(){const{chainId:e}=c.useWeb3React(),t=r.useSelector(le);return a.useMemo((()=>e||t||1),[e,t])}function De({tokenList:e,popularTokenList:t}){const n=r.useDispatch(),[o,s]=a.useState([]),{account:i}=c.useWeb3React(),l=Le(),d=r.useSelector(ce),u=a.useMemo((()=>(null==t?void 0:t.filter((e=>e.chainId===l)))||[]),[t,l]),p=a.useMemo((()=>{const e=o.map((({address:e})=>e));return null==t||t.forEach((({address:t})=>{e.includes(t)||e.push(t)})),e}),[o,t]);!function({tokenList:e,addresses:t,blockNumber:n}){const{account:o}=c.useWeb3React(),s=r.useDispatch(),i=a.useMemo((()=>[...(null==e?void 0:e.map((e=>e.address)))||[],...t||[]].map((e=>e.toLocaleLowerCase()))),[e,t]),{getContract:l,contractConfig:d,call:u}=be(),[p,m]=a.useState(),f=a.useMemo((()=>{if(!o||!i.length||!d)return;const{DODO_APPROVE:e,ERC20_HELPER:t}=d,n=l(t,ge);if(!n)return;let a={};const r=i.map((s=>(a[s]=!0,{callData:{data:n.interface.encodeFunctionData("isERC20",[s,o,e]),to:t},processor:e=>{const t=new h.Interface(ge).decodeFunctionResult("isERC20",e),{balance:n,isOk:o}=t,a=parseInt(t.decimals),r=new k.default(10).pow(a),i=new k.default(t.allownance.toString()).div(r);return o?{address:s,decimals:a,symbol:t.symbol,name:t.name,balance:new k.default(n.toString()).div(r),allowance:i}:{address:s,balance:new k.default(0),allowance:new k.default(0)}}})));return s(ue(a)),r}),[o,l,i]);a.useEffect((()=>{(()=>{X(this,void 0,void 0,(function*(){if(!f)return;const e=yield u(f),t={};e&&(e.forEach((e=>{t[e.address.toLocaleLowerCase()]={tokenBalances:e.balance,tokenAllowances:e.allowance}})),s(de(t))),m(e);let n={};i.forEach((e=>{n[e]=!1})),s(ue(n))}))})()}),[f,n])}({addresses:p,blockNumber:d}),a.useEffect((()=>{(()=>{X(this,void 0,void 0,(function*(){let t=[];if(e)t=e;else{t=(yield Promise.resolve().then((function(){return require("./tokenList-ee5e15c8.cjs")}))).default}const o=l,a=t.filter((e=>e.chainId===o));s(a),n((e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_TOKEN_LIST",payload:e})})))(a))}))})()}),[e,n,l]),a.useEffect((()=>{n(de({}))}),[i,l]),a.useEffect((()=>{n((e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_POPULAR_TOKEN_LIST",payload:e})})))(u))}),[u,n])}const Ne=e=>(null!=e?e:ie.getState()).token.tokenList,Me=e=>(null!=e?e:ie.getState()).token.accountBalances,_e=e=>(null!=e?e:ie.getState()).token.ethBalance||new k.default(NaN),Pe=e=>(null!=e?e:ie.getState()).token.defaultFromToken,Fe=e=>(null!=e?e:ie.getState()).token.defaultToToken,Ue=e=>(null!=e?e:ie.getState()).token.balanceLoadings;function We(){const{account:e,chainId:t}=c.useWeb3React(),n=r.useSelector(Me),o=r.useSelector(_e),s=a.useMemo((()=>V[t||1]),[t]),i=a.useCallback((t=>{var a;if(!e)return null;if(t.symbol===s.symbol&&F(t.address,s.address))return!o||(null==o?void 0:o.isNaN())?null:o;const r=null===(a=n[t.address.toLocaleLowerCase()])||void 0===a?void 0:a.tokenBalances;return!r||(null==r?void 0:r.isNaN())?null:r}),[n,o,e]);return i}var He;function $e(e,t,n,o=0){if(n&&(e=e.toLocaleLowerCase(),t=t.toLocaleLowerCase()),e===t)return He.fully+o;const s=e.indexOf(t);return 0===s?He.prefix+o:s>0?He.other+o:He.none}!function(e){e[e.fully=1]="fully",e[e.prefix=2]="prefix",e[e.other=3]="other",e[e.none=0]="none"}(He||(He={}));function ze({value:e,onChange:t,occupiedAddrs:n,hiddenAddrs:o,showAddrs:s}){const[i,l]=a.useState(""),c=r.useSelector(Ne),d=Le(),u=We(),p=a.useMemo((()=>new Set(o?o.map((e=>e.toLowerCase())):void 0)),[o]),m=a.useMemo((()=>s?new Set(s.map((e=>e.toLowerCase()))):void 0),[s]),h=a.useCallback((e=>e.filter((e=>{if(e.chainId!==d)return!1;let t=!0;return t=m?m.has(e.address.toLowerCase()):!p.has(e.address.toLowerCase()),t}))),[m,d,p]),f=a.useCallback((t=>{if(null===t)return null;const o=[];i?t.forEach((e=>{const t=((e,t,{matchAddress:n}={})=>{if(!t)return 0;const o=t.toLocaleLowerCase();let s=0;n&&e.address.toLocaleLowerCase()===o&&(s=1),s||(s=$e(e.symbol.toLocaleLowerCase(),o,!1,1));if(s)e.name.toLocaleLowerCase()===o&&(s=He.fully+1);else{let t=$e(e.name.toLocaleLowerCase(),o,!1,10);t=t===He.fully+10?He.fully+1:t,s=t}return s})(e,i,{matchAddress:!0});t&&o.push({sort:t,token:e})})):t.forEach((e=>{o.push({sort:0,token:e})}));const s=[];return o.sort(((t,o)=>{const s=t.token,a=o.token;if(e){if(s.address===e.address)return-1;if(a.address===e.address)return 1}if(null==n?void 0:n.includes(s.address))return-1;if(null==n?void 0:n.includes(a.address))return 1;const r=u&&u(s)||new k.default(0),i=u&&u(a)||new k.default(0);return r.eq(i)?t.sort!==o.sort?t.sort>o.sort?1:-1:s.symbol.localeCompare(a.symbol):r.gt(i)?-1:1})).some((e=>!!(i&&s.length>21)||(s.push(e.token),!1))),s}),[i,u,n,e]),x=a.useCallback((e=>{const o=e.address.toLowerCase();t(e,!!(null==n?void 0:n.some((e=>e.toLowerCase()===o))))}),[t,n]),b=a.useMemo((()=>{const e=h(c);return f(e)||[]}),[c,h,f]);return{filter:i,setFilter:l,showTokenList:b,onSelectToken:x}}function Ve({width:e=24,height:t=24,marginRight:n=8,url:s,zIndex:i,cross:l,address:d,token:u,sx:p}){const[m,h]=a.useState(!1),[f,x]=a.useState(""),[b,g]=a.useState(""),[y,v]=a.useState(!1),C=a.useCallback((()=>h(!0)),[]);let w=function(e){const t=r.useSelector(Ne),{chainId:n}=c.useWeb3React();return a.useMemo((()=>{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])}(d);u&&(w=u);const j=d||(null==w?void 0:w.address),T=null==w?void 0:w.symbol,A=null==T?void 0:T.charAt(0).toUpperCase(),O=a.useMemo((()=>{const e=null==w?void 0:w.logoURI;return s||e||""}),[s,w]);return a.useEffect((()=>{v(!1)}),[j,O]),a.useEffect((()=>{l&&(O?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()}}(O,(e=>{x(e)})):x(""))}),[O,l]),a.useEffect((()=>{try{let t=j;if(t&&t.length<15&&(t=t.padEnd(15,"0")),t){const n=new R.default(t,{size:e,format:"svg",margin:.2,background:[255,234,4,255]}).toString();g(`data:image/svg+xml;base64,${n}`)}}catch(e){console.error("generate Identicon error: ",e)}}),[j,e]),E.jsxs(o.Box,{sx:Object.assign({position:"relative",display:"flex",alignItems:"center",justifyContent:"center",minWidth:e,width:e,height:t,marginRight:n,zIndex:i},p||{}),style:{width:e,height:t},children:[!m&&E.jsx(o.Box,{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:A}),E.jsx(o.Box,{component:"img",src:!(l?f:O)||y?b:l?f:O,onLoad:C,onError:e=>{const t=e.target;j&&b&&v(!0),t.onerror=null},sx:{position:"absolute",top:"0",bottom:"0",left:"0",right:"0",borderRadius:"50%",overflow:"hidden",width:"100%",height:"100%"}})]})}function qe({token:t,onClick:n}){var s,a;const r=o.useTheme();return E.jsxs(o.Box,{component:o.BaseButton,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)?E.jsxs(E.Fragment,{children:[E.jsx(Ve,{address:null!==(s=null==t?void 0:t.address)&&void 0!==s?s:"",marginRight:6}),E.jsx(o.Box,{children:null!==(a=null==t?void 0:t.symbol)&&void 0!==a?a:"-"})]}):E.jsx(e.Trans,{id:"SELECT TOKEN"}),E.jsx(o.Box,{sx:{ml:7,width:12,transform:"rotateX(180deg)"},component:i.CaretUp})]})}function Ke({onClick:t,balance:n,decimals:s,address:a,showMaxBtn:r}){const{palette:i}=o.useTheme();return E.jsxs(o.Box,{sx:{display:"flex",typography:"body2",color:i.text.secondary},children:[E.jsx(e.Trans,{id:"Balance:"})," ",a?D({input:n,decimals:Math.min(s||4,4)}):"-",r&&n&&n.gt(0)&&E.jsx(o.Box,{component:o.BaseButton,sx:{ml:6,color:(null==n?void 0:n.gt(0))?i.primary.main:i.text.disabled,cursor:a&&t?"pointer":"unset"},onClick:()=>t&&t(n?n.toString():""),children:E.jsx(e.Trans,{id:"Max"})})]})}function Ge({readOnly:e,sx:t,value:n,decimals:s,onChange:r,suffix:l,withClear:c,placeholder:d}){const u=o.useTheme(),p=a.useMemo((()=>l||(c&&n&&r?E.jsx(o.Box,{component:o.BaseButton,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},onClick:()=>{r&&r("")},children:E.jsx(o.Box,{component:i.Error,sx:{width:12,color:"text.primary"}})}):void 0)),[r,l,u.palette.text.primary,n,c]);return E.jsxs(o.Box,{sx:Object.assign({mt:12,display:"flex",justifyContent:"space-between",alignItems:"center"},t),"data-testid":"number-input-wrapper",children:[E.jsx(o.Input,{fullWidth:!0,value:n,readOnly:e,placeholder:d||"0.00",onChange:e=>{const t=e.target.value,n=0===t.length?"":_(t,s);r&&r(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&&p]})}function Ye({open:e,onClose:t,title:n,rightSlot:s,canBack:a=!0,children:r,height:l,testId:c}){return E.jsxs(o.Box,{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:l},"data-testid":c,"data-active":e?"1":"0",children:[n?E.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:20},children:[E.jsx(o.Box,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:n}),s,!s&&a&&E.jsx(o.Box,{component:i.Error,sx:{color:"text.secondary",cursor:"pointer"},onClick:t})]}):"",r]})}const Xe=e=>(null!=e?e:ie.getState()).globals;function Ze({token:e,disabled:t,onClick:n}){return E.jsxs(o.Box,{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:[E.jsx(Ve,{token:e}),e.symbol]})}function Qe({token:e,disabled:t,style:n,onClick:s}){const a=We()(e),r=a?L({input:a}):"";return E.jsxs(o.Box,{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||s()},"data-testid":"token-picker-item",children:[E.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[E.jsx(Ve,{token:e}),E.jsxs(o.Box,{children:[E.jsx(o.Box,{sx:{fontWeight:600,textAlign:"left"},children:e.symbol}),E.jsx(o.Box,{sx:{mt:4,textAlign:"left"},children:r})]})]}),E.jsx(o.Box,{sx:{color:"text.secondary"},children:e.name})]})}function Je({value:e,onChange:t,occupiedAddrs:n,hiddenAddrs:s,showAddrs:i,visible:l}){var c;const d=Le(),u=r.useSelector((e=>((e,t)=>(null!=t?t:ie.getState()).token.popularTokenList.filter((({chainId:t})=>e===t)))(d,e))),{showTokenList:p,filter:m,setFilter:h,onSelectToken:f}=ze({value:e,onChange:t,occupiedAddrs:n,hiddenAddrs:s,showAddrs:i}),x=a.useRef(null),b=a.useRef(null),[g,y]=a.useState(0);a.useEffect((()=>{l&&x.current&&y(x.current.offsetHeight-34)}),[x,l]);const w=a.useCallback((({index:t,style:n})=>{const s=!!(null==u?void 0:u.length);if(0===t&&s)return E.jsx(o.Box,{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:b,style:Object.assign(Object.assign({},n),{visibility:n.height?"visible":"hidden",height:n.height?n.height:"auto"}),children:u.map((t=>E.jsx(Ze,{token:t,disabled:(null==e?void 0:e.address)===t.address,onClick:()=>f(t)},t.address)))});const a=p[s?t-1:t];return E.jsx(Qe,{token:a,disabled:!!e&&e.address===a.address,style:n,onClick:()=>f(a)})}),[p,u,b,e]),j=a.useCallback((e=>{var t;if(0===e&&(null==u?void 0:u.length)){const e=(null===(t=b.current)||void 0===t?void 0:t.offsetHeight)||0;return e<=52?0:e}return 52}),[b,u]);return E.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",px:20,flex:1},children:[E.jsx(o.SearchInput,{fullWidth:!0,height:48,value:m,onChange:e=>h(e.target.value),clearValue:()=>h(""),placeholder:v.i18n._("Enter the token symbol or address")}),E.jsx(o.Box,{sx:{mt:16,pb:16,flex:1,minHeight:64},ref:x,children:E.jsx(C.VariableSizeList,{height:g,itemCount:p.length+((null==u?void 0:u.length)?1:0),itemSize:j,width:"100%",className:"token-list",children:w},null===(c=b.current)||void 0===c?void 0:c.offsetHeight)})]})}function et({open:t,value:n,onClose:o,occupiedAddrs:s,onTokenChange:a}){const{height:i}=r.useSelector(Xe);return E.jsx(Ye,{height:i,open:t,onClose:o,title:E.jsx(e.Trans,{id:"Select a token"}),testId:"token-picker-wrapper",children:E.jsx(Je,{value:n,visible:t,onChange:a,occupiedAddrs:s})})}function tt({sx:e,amt:t,token:n,readOnly:s,showMaxBtn:r,onMaxClick:i,fiatPriceTxt:l,occupiedAddrs:c,onInputChange:d,onTokenChange:u}){const p=o.useTheme(),m=We(),[h,f]=a.useState(!1),x=n?m(n):null;return E.jsxs(o.Box,{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:[E.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[E.jsx(qe,{token:n,onClick:()=>f(!0)}),E.jsx(Ke,{balance:x,onClick:i,showMaxBtn:r,address:null==n?void 0:n.address,decimals:null==n?void 0:n.decimals})]}),E.jsx(Ge,{value:t,onChange:d,readOnly:s,withClear:!0}),E.jsx(o.Box,{sx:{mt:4,typography:"body2",color:p.palette.text.secondary},children:l}),E.jsx(et,{value:n,open:h,occupiedAddrs:c,onClose:()=>f(!1),onTokenChange:(e,t)=>{u(e,t),f(!1)}})]})}const nt={"en-US":w.en,"zh-CN":w.zh,pseudo:w.en};function ot({locale:t,children:n}){return a.useEffect((()=>{(()=>{X(this,void 0,void 0,(function*(){yield function(e="en-US"){return X(this,void 0,void 0,(function*(){v.i18n.loadLocaleData(e,{plurals:()=>nt[e]});try{const n=yield(t=`./locales/${e}.js`,Promise.resolve().then((function(){return B(require(t))})));v.i18n.load(e,n.messages||n.default.messages)}catch(e){}var t;v.i18n.activate(e)}))}(t)}))})()}),[t]),E.jsx(e.I18nProvider,{i18n:v.i18n,children:n})}var st,at,rt;!function(e){e[e.Running=0]="Running",e[e.Success=1]="Success",e[e.Failed=2]="Failed",e[e.Warning=3]="Warning"}(st||(st={})),function(e){e.Canceled="canceled",e.Failed="failed",e.Success="success",e.Submitted="submitted"}(at||(at={})),function(e){e[e.Failed=0]="Failed",e[e.Success=1]="Success"}(rt||(rt={}));var it,lt=[{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"}(it||(it={}));const ct=(e,t)=>X(void 0,void 0,void 0,(function*(){const{value:n,from:o,to:s,data:a}=e,r={from:o,to:s,value:n,data:a};n&&!/^0x0*$/.test(n)||delete r.value;try{return(yield t.estimateGas(r)).add(5e4)}catch(e){t.call(r).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})),dt=(e,t)=>X(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(v.i18n._("Transaction rejected.")):e}}));var ut,pt;!function(e){e.Approval="APPROVAL",e.TX="TX",e.TypedSign="TypedSign"}(ut||(ut={})),function(e){e.Normal="Normal",e.Privacy="Privacy",e.LimitOrder="LimitOrder",e.RFQ="RFQ"}(pt||(pt={}));const mt=new k.default(2).pow(256).minus(1);function ht({onTxFail:e,onTxSubmit:t,onTxSuccess:n}={}){const{account:o,provider:s}=c.useWeb3React(),r=Le(),[i,l]=a.useState(!1),[d,u]=a.useState(new Map),[p,m]=a.useState(null),[h,f]=a.useState(""),[x,b]=a.useState(null),[g,y]=a.useState(!1),[E,C]=a.useState(),w=a.useCallback(((a,i,c,d=!1,p,h,x,g)=>X(this,void 0,void 0,(function*(){if(f(""),m(""),!o||!s)throw new Error("Submission: Cannot execute step when the wallet is disconnected");let E,w,j;C((()=>x)),l(!1);try{if(l(!0),i.opcode===ut.Approval)j=yield((e,t,n,o,s,a)=>X(void 0,void 0,void 0,(function*(){const r=xe(e,lt,s,a).interface.encodeFunctionData("approve",[n,o.toFixed()]),i={from:t,to:e,data:r,value:`0x${new k.default("0").toString(16)}`,gasLimit:void 0},l=yield ct(i,s);return l&&(i.gasLimit=l),yield dt(i,s)})))(i.token.address,o,i.contract,i.amt||mt,s,o),E=j.hash,f(E);else{if(i.opcode!==ut.TX)throw new Error(`Op ${i.opcode} not implemented!`);if(""===i.to)throw new Error("Submission: malformed to");if(0===i.data.length)throw new Error("Submission: malformed data");if(0===i.data.indexOf("0x")&&i.data.length<=2)throw new Error("Submission: malformed data");if(w={value:i.value,data:i.data,to:i.to,gasLimit:i.gasLimit,from:o,chainId:r},!w.gasLimit)try{const e=yield ct(w,s);e&&(w.gasLimit=e)}catch(e){console.debug(e)}if(j=yield dt(w,s),E=j.hash,f(E),!E)throw new Error(`Unexpected tx: ${E}`)}}catch(t){if(l(!1),b({spec:i,brief:a,subtitle:c}),console.error(t),t.message){const n={error:t.message,brief:a};h&&Object.assign(n,h),e&&e(t,h),m(function(e,t){var n;const o=null===(n=V[e])||void 0===n?void 0:n.symbol,s=[{error:"insufficient",msg:v.i18n._("Insufficient funds - Please retry after depositing more {EtherTokenSymbol} into your wallet",{EtherTokenSymbol:o})},{error:["External Swap execution Failed","Return amount is not enough"],msg:v.i18n._("Price impact exceeds the slippage tolerance you set. Try increasing the slippage tolerance.")},{error:"SafeERC20: low-level call failed",msg:v.i18n._("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:v.i18n._("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:v.i18n._("RPC node data exception")},{error:['execution reverted:FORCESTOP ["originalError"'],msg:v.i18n._("ForceStop exception")},{error:["replacement transaction underpriced","Gasprice too low","transaction underprice"],msg:v.i18n._("Gas price is too low, please adjust in your wallet and try again")},{error:["MINT_INVALID"],msg:v.i18n._("No ForceStop access")},{error:["NOT_PHASE_EXE"],msg:v.i18n._("Unable to SETTLE during the cooling-off period")},{error:["params specify an EIP-1559transaction but the currentnetwork does not support"],msg:v.i18n._("Wallet incompatibility")},{error:["ALREADY_SETTLED"],msg:v.i18n._("This CP has been settled by other addrs")},{error:["create RFQ order failed]:LESS_THAN_FEE_LIMIT"],msg:v.i18n._("Service update, please wait and try again")}];let a="";return s.some((e=>Array.isArray(e.error)?e.error.some((n=>t.indexOf(n)>-1&&(a=e.msg,!0))):t.indexOf(e.error)>-1&&(a=e.msg,!0))),a||t}(r,t.message))}return at.Failed}b({spec:i,brief:a,subtitle:c}),y(!1),l(!1);const T=Object.assign(Object.assign(Object.assign(Object.assign({brief:a},i),w),{tx:E,subtitle:c}),h);t&&t(E,T),p&&p();const A={brief:a,spec:i,tx:E,subtitle:c};if(u((e=>e.set(E,[A,st.Running]))),d)return at.Submitted;if(p&&p(),null==j?void 0:j.wait){const e=yield j.wait(1);if(y(!0),e.status===rt.Success)return g&&g(E),n&&n(E,T),u((e=>e.set(E,[A,st.Success]))),at.Success}return y(!0),u((e=>e.set(E,[A,st.Failed]))),at.Failed}))),[o,r,l,s]),j=a.useMemo((()=>({execute:w,requests:d,setShowing:b,waitingSubmit:i})),[w,d,b]),T=a.useCallback((()=>{b(null),E&&(E(),C(void 0))}),[E]);return{showing:x,showingDone:g,transactionTx:h,errorMessage:p,setErrorMessage:m,closeShowing:T,ctxVal:j,requests:d}}function ft(){const{requests:e}=bt(),t=[];return null==e||e.forEach((function([e,n]){n===st.Running&&t.push(e)})),{runningRequests:t,isInflight:t.length>0}}const xt=a.createContext({execute:()=>Promise.resolve(at.Canceled),requests:void 0,waitingSubmit:!1});function bt(){return a.useContext(xt)}var gt;function yt(){return yt=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},yt.apply(this,arguments)}var Et=function(e){return S.createElement("svg",yt({width:"33px",height:"33px",viewBox:"0 0 33 33",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),gt||(gt=S.createElement("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},S.createElement("g",{transform:"translate(-186.000000, -375.000000)",stroke:"currentColor",strokeWidth:4},S.createElement("g",{transform:"translate(18.000000, 291.000000)"},S.createElement("g",{transform:"translate(40.000000, 83.000000)"},S.createElement("path",{d:"M159,32 C159,15.9837423 146.016258,3 130,3"})))))))};function vt({showingDone:e,errorMessage:t}){return t?E.jsx(o.Box,{component:i.ErrorWarn,sx:{width:64,height:64,color:"error.main"}}):e?E.jsx(o.Box,{component:i.DoneBorder,sx:{width:64,height:64,color:"success.main"}}):E.jsx(o.Box,{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:E.jsx(o.Box,{component:Et,sx:{position:"absolute",top:"-6px",right:"-6px",color:"primary.main"}})})}function Ct({showingDone:e,showing:t}){return E.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:[E.jsx(o.Box,{sx:{mt:60},children:e?v.i18n._("{0} confirmed",{0:null==t?void 0:t.brief}):v.i18n._("{0} pending",{0:null==t?void 0:t.brief})}),(null==t?void 0:t.subtitle)?E.jsx(o.Box,{sx:{mt:20,typography:"body2"},children:null==t?void 0:t.subtitle}):""]})}function wt({isStarted:t,isEnded:n,tx:s}){const[r,l]=a.useState(0),{chainId:d}=c.useWeb3React(),u=a.useMemo((()=>`https://${K[d||1]}/tx/${s}`),[s,d]),p=a.useMemo((()=>{const e=Math.floor(r/60),t=r%60;return e?`${e}m ${t}s`:`${t}s`}),[r]),m=a.useRef();return a.useEffect((()=>(l(0),m.current=setInterval((()=>{l((e=>e+1))}),1e3),()=>{clearInterval(m.current)})),[t]),a.useEffect((()=>{clearInterval(m.current)}),[n]),E.jsxs(o.Box,{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:[E.jsxs(o.Box,{children:[E.jsx(e.Trans,{id:"Transaction Time:"}),p]}),E.jsxs(o.HoverOpacity,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},component:"a",href:u,target:"_blank",rel:"noopener noreferrer",children:[E.jsx(e.Trans,{id:"View on Etherscan"}),E.jsx(o.Box,{component:i.ArrowTopRightBorder,sx:{width:16,height:16,ml:6}})]})]})}function jt(t){var{children:n}=t,s=Y(t,["children"]);const{ctxVal:a,showing:r,closeShowing:i,showingDone:l,errorMessage:c,transactionTx:d}=ht(s);return E.jsxs(xt.Provider,{value:a,children:[n,E.jsx(Ye,{open:!!r,onClose:i,children:E.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",px:20,pb:20,flex:1,overflowY:"auto"},children:[E.jsxs(o.Box,{children:[E.jsx(o.Box,{sx:{textAlign:"center",pt:60},children:E.jsx(vt,{showingDone:l,errorMessage:c})}),c?E.jsxs(o.Box,{sx:{textAlign:"center",mt:60},children:[E.jsx(o.Box,{children:E.jsx(e.Trans,{id:"Something went wrong."})}),E.jsx(o.Box,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:c})]}):E.jsxs(E.Fragment,{children:[E.jsx(Ct,{showingDone:l,showing:r}),E.jsx(wt,{isStarted:!!r,isEnded:l,tx:d})]})]}),E.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,onClick:i,sx:{mt:20},children:c?E.jsx(e.Trans,{id:"Dismiss"}):E.jsx(e.Trans,{id:"Close"})})]})})]})}const Tt=e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_GLOBAL_PROPS",payload:e})}));function At({width:e,height:t,feeRate:n,rebateTo:o,colorMode:s,apikey:i,defaultChainId:l,defaultToToken:c,defaultFromToken:d}){const u=r.useDispatch();a.useEffect((()=>{s&&u((e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_COLOR_MODE",payload:e})})))(s))}),[s]),a.useEffect((()=>{var e;l&&u((e=l,t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_CHAIN_ID",payload:e})}))))}),[l]),a.useEffect((()=>{u(Tt({height:t}))}),[t]),a.useEffect((()=>{u(Tt({width:e}))}),[e]),a.useEffect((()=>{i&&u(Tt({apikey:i}))}),[i]),a.useEffect((()=>{n&&u(Tt({feeRate:n}))}),[n]),a.useEffect((()=>{o&&u(Tt({rebateTo:o}))}),[o]),a.useEffect((()=>{d&&u((e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_DEFAULT_FROM_TOKEN",payload:e})})))(d))}),[d]),a.useEffect((()=>{c&&u((e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_DEFAULT_TO_TOKEN",payload:e})})))(c))}),[c])}function Ot({refetch:e,interval:t}){let n;a.useEffect((()=>(e(),clearTimeout(n),n=setInterval((()=>{e()}),null!=t?t:15e3),()=>clearTimeout(n))),[e])}function Bt({fromToken:e,toToken:t,chainId:n}){const[o,s]=a.useState(!1),[r,i]=a.useState(""),[l,c]=a.useState(""),d=a.useCallback((()=>{if(!n||!e||!t)return;s(!0);const o=[e,t];I.default.post("https://api.dodoex.io/price-api/api/v1/price/current/batch",{networks:o.map((()=>(e=>q[e]||q[H.MAINNET])(n))),addresses:o.map((e=>e.address)),symbols:o.map((e=>e.symbol)),isCache:!0},{headers:{apikey:"dodofrontend777888ofopensource"}}).then((n=>{var o;s(!1);const a=null===(o=n.data)||void 0===o?void 0:o.data;a&&(i(a.find((t=>t.address===e.address)).price),c(a.find((e=>e.address===t.address)).price))})).catch((e=>{s(!1),console.error(e)}))}),[n,e,t]);return Ot({refetch:d}),{loading:o,refetch:d,toFiatPrice:l,fromFiatPrice:r}}const kt=e=>(null!=e?e:ie.getState()).settings.slippage,St=e=>(null!=e?e:ie.getState()).settings.ddl;var Rt;function It({toToken:e,fromToken:t,fromAmount:n,marginAmount:o}){const{account:s,chainId:i,provider:l}=c.useWeb3React(),d=r.useSelector(le),u=a.useMemo((()=>i||d),[i,d]),p=r.useSelector(kt)||3,m=r.useSelector(St)||20,{feeRate:h,rebateTo:f,apikey:x}=r.useSelector(Xe),b=a.useMemo((()=>Math.floor(Date.now()/1e3)+60*m),[m]),[g,y]=a.useState(Rt.Initial),[E,C]=a.useState(null),[w,j]=a.useState(null),[A,O]=a.useState(null),[B,S]=a.useState(null),[R,L]=a.useState(T.BigNumber.from(0)),[D,N]=a.useState(null),[M,_]=a.useState(null),[P,F]=a.useState(""),[U,W]=a.useState(""),[$,z]=a.useState(""),[V,q]=a.useState(0),K=a.useCallback((()=>X(this,void 0,void 0,(function*(){if(!u||!t||!e)return;y(Rt.Loading);const a={chainId:u,deadLine:b,apikey:x,slippage:p,source:"dodoV2AndMixWasm",toTokenAddress:e.address,toTokenDecimals:e.decimals,fromTokenAddress:t.address,fromTokenDecimals:t.decimals,userAddr:s||"0x0000000000000000000000000000000000000000",fromAmount:T.parseFixed(String(n||1),t.decimals).toString()};new k.default(o).isNaN()||(a.marginAmount=o),f&&h&&(a.rebateTo=f,a.fee=h);try{const e=(yield I.default.get("https://api.dodoex.io/route-service/v2/widget/getdodoroute",{params:a})).data.data;(null==e?void 0:e.resAmount)?(y(Rt.Success),C(e.resAmount),S(e.priceImpact),N(e.resPricePerFromToken),_(e.resPricePerToToken),j(e.baseFeeAmount),O(e.additionalFeeAmount),F(e.to),W(e.data),z(e.useSource),q(e.duration)):y(Rt.Failed);const t=G({tokenAmount:new k.default(n),tokenAddress:a.fromTokenAddress,chainId:a.chainId});if(!s||!l||!n)return;const o=yield ct({from:s,to:e.to,value:t,data:e.data},l);o&&L(o)}catch(e){y(Rt.Failed),console.error(e)}}))),[b,s,u,e,h,p,f,t,l,n,x]);Ot({refetch:K});const Y=a.useMemo((()=>g!==Rt.Loading&&n?E:null),[g,n,E]),Z=function(){const{chainId:e,account:t}=c.useWeb3React(),n=bt();return a.useCallback((({fromTokenAddress:o,parsedFromAmt:s,to:a,data:r,useSource:i,duration:l,ddl:c,gasLimit:d,subtitle:u})=>{const p=60*c,m=e||H.MAINNET,h=G({tokenAmount:s,tokenAddress:o,chainId:m});i&&"weth"!==i.toLowerCase()&&d&&d.lt(3e4)&&console.debug("Warning: GasLimit less than the minimum!");const f={from:t,to:a,data:r,value:h,route:i,duration:l,ddlSecRel:p,gasLimit:d};n.execute(v.i18n._("Swap"),Object.assign({opcode:ut.TX},f),u)}),[t,e])}(),Q=a.useCallback((e=>{t&&n&&Z({to:P,data:U,useSource:$,duration:V,ddl:m,fromTokenAddress:t.address,parsedFromAmt:new k.default(n),gasLimit:R,subtitle:e})}),[P,m,U,V,$,t,n,R]);return{status:g,refetch:K,priceImpact:B,executeSwap:Q,baseFeeAmount:w,resAmount:Y,additionalFeeAmount:A,resPricePerToToken:M,resPricePerFromToken:D}}!function(e){e.Initial="Initial",e.Loading="Loading",e.Failed="Failed",e.Success="Success"}(Rt||(Rt={}));function Lt(e){De(e),ye(),Ee();const{provider:t,connector:n}=c.useWeb3React();a.useEffect((()=>{const t=e.defaultChainId||1;(null==n?void 0:n.connectEagerly)?n.connectEagerly(t):n.activate(t)}),[n]),a.useEffect((()=>{const e=null==t?void 0:t.provider;e&&e.once&&e.once("chainChanged",(()=>{setTimeout((()=>{window.location.reload()}),200||100)}))}),[t]);const s=e.width||375,r=e.height||494;return At(Object.assign(Object.assign({},e),{width:s,height:r})),E.jsx(o.Box,{sx:{width:s,height:r,overflow:"hidden",position:"relative",display:"flex",flexDirection:"column",minWidth:335,minHeight:494,borderRadius:16,backgroundColor:"background.paper"},className:"dodo-widget-container",children:E.jsx(jt,{...e,children:e.children})})}function Dt(e){const t=o.createTheme({mode:e.colorMode,theme:e.theme,lang:e.locale||"en-US"}),n=a.useMemo((()=>e.defaultChainId||1),[e.defaultChainId]),s=Ie({provider:e.provider,jsonRpcUrlMap:e.jsonRpcUrlMap,defaultChainId:n}),i=`${s.length}+${e.jsonRpcUrlMap?Object.entries(e.jsonRpcUrlMap):""}+${e.defaultChainId}+${n}`;return E.jsx(r.Provider,{store:ie,children:E.jsx(ot,{locale:e.locale,children:E.jsx(o.ThemeProvider,{theme:t,children:E.jsxs(c.Web3ReactProvider,{connectors:s,children:[E.jsx(o.CssBaseline,{container:".dodo-widget-container"}),E.jsx(Lt,{...e})]},i)})})})}function Nt(e){const{width:t}=r.useSelector(Xe),n=a.useMemo((()=>{let e="";return"number"==typeof t?e=`${t}px`:t&&(e=t),e?`calc(${e} - 40px)`:"auto"}),[t]);return E.jsx(o.QuestionTooltip,{container:document.querySelector(".dodo-widget-container"),maxWidth:n,...e})}function Mt({onClick:e}){const t=o.useTheme();return E.jsx(o.HoverOpacity,{sx:{width:"100%",position:"relative"},onClick:e,children:E.jsx(o.Box,{component:o.BaseButton,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:E.jsx(o.Box,{component:i.ArrowBack,sx:{width:18,color:"text.secondary"}})})})}function _t({open:t,execute:n,onClose:s,toToken:l,fromToken:c,fromAmount:d,toAmount:u,priceImpact:p,clearFromAmt:m,baseFeeAmount:h,curToFiatPrice:f,curFromFiatPrice:x,pricePerFromToken:b,additionalFeeAmount:g}){var y,v;const C=o.useTheme(),{isInflight:w}=ft(),j=r.useSelector(kt),T=a.useMemo((()=>new k.default(p).gt(15)),[p]),[A,O]=a.useState(!1),[B,S]=a.useState(!1),[R,I]=a.useState(!1);return a.useEffect((()=>{w&&(s(),m(),I(!1))}),[w]),a.useEffect((()=>{O(!1)}),[f]),E.jsx(Ye,{open:t,onClose:()=>{I(!1),s()},title:E.jsx(e.Trans,{id:"Swap summary"}),children:E.jsxs(o.Box,{sx:{margin:20,display:"flex",height:"100%",flexDirection:"column",borderTop:`1px solid ${C.palette.border.main}`},children:[E.jsxs(o.Box,{sx:{py:20,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexDirection:"column",borderBottom:`1px solid ${C.palette.border.main}`},children:[E.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[E.jsxs(o.Box,{children:[E.jsxs(o.Box,{sx:{display:"flex"},children:[E.jsx(Ve,{width:16,height:16,address:null!==(y=null==c?void 0:c.address)&&void 0!==y?y:"",marginRight:6}),E.jsx(o.Box,{children:`${d} ${null==c?void 0:c.symbol}`})]}),E.jsx(o.Box,{sx:{mt:4,typography:"h6",color:C.palette.text.secondary},children:x?`$${L({input:x,showDecimals:1})}`:"-"})]}),E.jsx(o.Box,{sx:{width:16,mx:16},component:i.DoubleRight}),E.jsxs(o.Box,{children:[E.jsxs(o.Box,{sx:{display:"flex"},children:[E.jsx(Ve,{width:16,height:16,marginRight:6,address:null!==(v=null==l?void 0:l.address)&&void 0!==v?v:""}),E.jsx(o.Box,{children:`${D({input:u,decimals:null==l?void 0:l.decimals})} ${null==l?void 0:l.symbol}`})]}),E.jsx(o.Box,{sx:{typography:"h6",mt:4,color:C.palette.text.secondary},children:f?`$${L({input:f,showDecimals:1})}(${p}%)`:"-"})]})]}),E.jsx(o.Box,{sx:{mt:12,typography:"h6"},children:`1 ${null==c?void 0:c.symbol} = ${D({input:u,decimals:null==l?void 0:l.decimals})} ${null==l?void 0:l.symbol}`})]}),E.jsxs(o.Box,{sx:{py:15,typography:"body2",borderBottom:`1px solid ${C.palette.border.main}`},children:[E.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",color:C.palette.text.secondary},children:[E.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[E.jsx(o.Box,{sx:{width:16,mr:7},component:i.DetailBorder}),E.jsx(e.Trans,{id:"Swap Detail"})]}),E.jsx(o.Box,{component:o.BaseButton,children:E.jsx(o.Box,{onClick:()=>S(!B),sx:{width:10,color:"text.secondary",transform:B?"rotateX(0deg)":"rotateX(180deg)"},component:i.CaretUp})})]}),E.jsxs(o.Box,{sx:{mt:16,display:B?"initial":"none"},children:[E.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[E.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[E.jsx(e.Trans,{id:"Basic Fee"}),E.jsx(Nt,{title:E.jsx(e.Trans,{id:"Estimated service provider fees"}),ml:5})]}),E.jsx(o.Box,{children:`${D({input:h,decimals:null==l?void 0:l.decimals})} ${null==l?void 0:l.symbol}`})]}),E.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[E.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[E.jsx(e.Trans,{id:"Additional Fee"}),E.jsx(Nt,{title:E.jsx(e.Trans,{id:"Additional routing fees set by the Widget user"}),ml:5})]}),E.jsx(o.Box,{children:`${D({input:g,decimals:null==l?void 0:l.decimals})} ${null==l?void 0:l.symbol}`})]}),E.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[E.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[E.jsx(e.Trans,{id:"Price Impact"}),E.jsx(Nt,{title:E.jsx(e.Trans,{id:"Due to the market condition, market price and estimated price may have a slight difference"}),ml:5})]}),E.jsx(o.Box,{children:`${p}%`})]}),E.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[E.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[E.jsx(e.Trans,{id:"Slippage"}),E.jsx(Nt,{title:E.jsx(e.Trans,{id:"High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:5})]}),E.jsx(o.Box,{children:j})]})]})]}),E.jsx(o.Box,{sx:{flex:1}}),T&&E.jsxs(o.Box,{sx:{mb:14,display:"flex",cursor:"pointer",justifyContent:"center",alignItems:"center",typography:"h6"},onClick:()=>O(!A),children:[E.jsx(o.Box,{sx:{mr:4,width:18,height:18,alignItems:"center"},children:A?E.jsx(o.Box,{sx:{width:"100%",height:"100%",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"secondary.main"},children:E.jsx(o.Box,{component:i.Done,sx:{width:14,color:"#1a1a1b"}})}):E.jsx(o.Box,{sx:{width:"100%",height:"100%",borderRadius:4,border:`1px solid ${C.palette.text.secondary}`}})}),E.jsx(o.Box,{children:E.jsx(e.Trans,{components:{0:E.jsx(o.Box,{component:"span",sx:{color:"error.main"}})},values:{priceImpact:p},id:"Price impact reaches <0>{priceImpact}</0>%, accept the quote"})})]}),E.jsx(o.Button,{isLoading:R,disabled:T&&!A,fullWidth:!0,onClick:()=>{n(),I(!0)},children:R?E.jsx(e.Trans,{id:"Confirming"}):E.jsx(e.Trans,{id:"Confirm swap"})})]})})}function Pt(e){var{sx:n,maxVal:s,decimals:a=2,onInputChange:r}=e,i=Y(e,["sx","maxVal","decimals","onInputChange"]);return o.useTheme(),E.jsx(o.Input,{...i,onChange:e=>{const n=0===e.target.value.length?null:_(e.target.value,a),o=s&&n&&new t.BigNumber(n).gt(s)?s.toString():n;console.log("finalVal:",o),r&&r(o)}})}function Ft({open:t,onClose:n}){const s=o.useTheme(),i=r.useDispatch(),l=r.useSelector(kt),c=r.useSelector(St),d=a.useMemo((()=>Number(l)>=50),[l]);return E.jsx(Ye,{open:t,onClose:n,title:E.jsx(e.Trans,{id:"Settings"}),children:E.jsxs(o.Box,{sx:{mx:20},children:[E.jsxs(o.Box,{sx:{py:20,borderTop:`1px solid ${s.palette.border.main}`},children:[E.jsxs(o.Box,{sx:{mb:16,display:"flex",alignItems:"center"},children:[E.jsx(e.Trans,{id:"Slippage Tolerance"}),E.jsx(Nt,{title:E.jsx(e.Trans,{id:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:7})]}),E.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column"},children:[E.jsx(Pt,{fullWidth:!0,maxVal:100,value:l,placeholder:3..toString(),onInputChange:e=>{i((e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_SLIPPAGE",payload:e})})))(e))},suffix:E.jsx(o.Box,{sx:{color:"text.disabled"},children:"%"}),height:36}),d&&E.jsx(o.Box,{sx:{typography:"h6",mt:6,color:"error.main"},children:E.jsx(e.Trans,{id:"Maximum slippage do not exceed 50%"})})]})]}),E.jsxs(o.Box,{sx:{py:20,borderTop:`1px solid ${s.palette.border.main}`},children:[E.jsxs(o.Box,{sx:{mb:16,display:"flex",alignItems:"center"},children:[E.jsx(e.Trans,{id:"Transaction Deadline"}),E.jsx(Nt,{title:E.jsx(e.Trans,{id:"If your transaction time exceeds the deadline, your transaction will be rescinded."}),ml:7})]}),E.jsx(Pt,{value:c,fullWidth:!0,height:36,placeholder:v.i18n._("{DEFAULT_SWAP_DDL} minutes",{DEFAULT_SWAP_DDL:20}),onInputChange:e=>{i((e=>t=>X(void 0,void 0,void 0,(function*(){t({type:"SET_TRANSACTION_DDL",payload:e})})))(e?Math.max(Number(e),1):""))}})]})]})})}function Ut({toToken:t,fromToken:n,priceStatus:s,pricePerToToken:r,pricePerFromToken:l}){const[c,d]=a.useState("-"),[u,p]=a.useState(null),[m,h]=a.useState("-"),[f,x]=a.useState(null);a.useEffect((()=>{d(null==n?void 0:n.symbol),h(null==t?void 0:t.symbol),p(r),x(l)}),[n,t,r,l]);const b=a.useCallback((()=>{d(m),h(c),p(f),x(u)}),[c,u,m,f]);return E.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:{[Rt.Initial]:"-",[Rt.Loading]:E.jsxs(E.Fragment,{children:[E.jsx(o.RotatingIcon,{sx:{mr:5}}),E.jsx(e.Trans,{id:"Fetching best price..."})]}),[Rt.Failed]:E.jsxs(E.Fragment,{children:[E.jsx(o.Box,{component:i.Warn,sx:{width:15,mr:5,color:"warning.main"}}),E.jsx(e.Trans,{id:"Quote not available"})]}),[Rt.Success]:E.jsxs(E.Fragment,{children:[E.jsx(o.Box,{sx:{typography:"body2"},children:`1 ${c} = ${L({input:f,showDecimals:4})} ${m}`}),E.jsx(o.Box,{component:o.BaseButton,sx:{width:18,height:18,ml:6,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},children:E.jsx(o.Box,{sx:{width:16,color:"text.secondary"},onClick:b,component:i.Switch})})]})}[s]})}function Wt({open:t,onClose:n}){const s=r.useSelector(le);return E.jsx(Ye,{title:E.jsx(e.Trans,{id:"Connect to your wallet"}),open:t,onClose:n,children:E.jsx(o.Box,{sx:{mx:20,pb:20,border:"1px solid transparent",borderTopColor:"border.main"},children:Object.values(Se).map((t=>E.jsxs(o.Box,{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 s=Re[e];if(!s)throw new Error(`Unknown wallet type: ${e}`);const[a]=s;null===(o=a.activate(t))||void 0===o||o.catch((e=>{4001!==e.code?n(e):a.connectEagerly?a.connectEagerly(t):a.activate(t)}))}(t.type,s,(e=>{console.error(e)}))},children:[E.jsx(o.Box,{component:t.icon,sx:{width:32,height:32}}),E.jsx(o.Box,{sx:{mt:8,typography:"caption"},children:t.name}),E.jsx(o.Box,{sx:{mt:4,typography:"body2",color:"text.secondary"},children:E.jsx(e.Trans,{id:"Connect to your {0} Wallet",values:{0:t.name}})})]},t.type)))})})}function Ht(){const{connector:t}=c.useWeb3React(),[n,s]=a.useState(!1);return E.jsxs(E.Fragment,{children:[E.jsx(o.Button,{size:o.Button.Size.big,fullWidth:!0,onClick:()=>{t.deactivate?t.deactivate():t.resetState(),s(!0)},"data-testid":"connect-wallet-btn",children:E.jsx(e.Trans,{id:"Connect to a wallet"})}),E.jsx(Wt,{open:n,onClose:()=>s(!1)})]})}var $t;!function(e){e.Loading="Loading",e.Insufficient="ApprovalInsufficient",e.Approving="Approving",e.Sufficient="Sufficient",e.Unchecked="Unchecked"}($t||($t={}));const zt=({account:e,chainId:t,offset:n,contractAddress:o})=>{var s;const i=r.useSelector(le),l=a.useMemo((()=>{var e;return me[null!==(e=t)&&void 0!==e?e:i]}),[t]),{isETH:d}=a.useMemo((()=>W(t)),[t]),{DODO_APPROVE:u}=l||{},p=null!==(s=null!=o?o:u)&&void 0!==s?s:null,m=function(e){const{account:t}=c.useWeb3React(),n=r.useSelector(le),o=r.useSelector(Me),s=a.useMemo((()=>V[n]),[n]),i=a.useCallback((n=>{var a;if(!t||!e)return null;if(n.symbol===s.symbol&&F(n.address,s.address))return new k.default(mt);const r=null===(a=null==o?void 0:o[n.address.toLowerCase()])||void 0===a?void 0:a.tokenAllowances;return null!=r?r:null}),[t,e,s.symbol,s.address,o]);return i}(p),h=We(),{runningRequests:f}=ft(),x=r.useSelector(Ue),b=a.useMemo((()=>{var e;return null===(e=V[null!=t?t:i])||void 0===e?void 0:e.address}),[t]),g=a.useCallback(((t,o,s)=>{if(!t)return $t.Loading;const a=!!(null==f?void 0:f.find((e=>e.spec.opcode===ut.Approval&&e.spec.token.address===(null==t?void 0:t.address)))),r=null!=s?s:t?h(t):null,i=t?m(t):null,l=new k.default(null!=o?o:0);if(!e)return $t.Unchecked;if(!r||l.minus(null!=n?n:0).gt(r))return $t.Unchecked;if(l.isZero())return $t.Unchecked;return t.address===b?$t.Sufficient:a?$t.Approving:i&&l.minus(null!=n?n:0).gt(i)?$t.Insufficient:$t.Sufficient}),[h,m,e,n,p,t,x,f,b]),y=a.useCallback((e=>{const t=e?m(e):null;return("USDT"===(null==e?void 0:e.symbol)||(null==e?void 0:e.address.toLowerCase())==="0x6426e6017968377529487E0ef0aA4E7759724e05".toLowerCase())&&null!==t&&t.gt(0)}),[m]),E=bt(),C=r.useDispatch(),w=a.useCallback(((t,n)=>X(void 0,void 0,void 0,(function*(){if(!p||!e||!t)return;const o=(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),s=n?new k.default(0):void 0,a=n?v.i18n._("Reset"):v.i18n._("Approve");var r;(yield E.execute(`${a} ${o}`,{opcode:ut.Approval,token:t,contract:p,amt:s}))===at.Success&&C((r=null!=s?s:mt,e=>X(void 0,void 0,void 0,(function*(){e({type:"SET_ACCOUNT_ALLOWANCES",payload:r})}))))}))),[p,e,t,E,C]),j=a.useCallback((e=>{const t=new k.default(0);if(!e)return t.toNumber();const n=h(e);if(!n)return t.toNumber();let o=n;const s=d?.1:.02;return b===(null==e?void 0:e.address)&&(o=n.gt(s)?n.minus(s):t),o.toNumber()}),[t,h,d]);return{getApprovalState:g,getPendingRest:y,getMaxBalance:j,submitApprove:w}};function Vt(){var t,s;const l=o.useTheme(),{isInflight:d}=ft(),{chainId:u,account:p}=c.useWeb3React(),m=r.useSelector(le),h=r.useSelector(Fe),f=r.useSelector(Pe),{isETH:x}=a.useMemo((()=>W(u)),[u]),b=a.useMemo((()=>{var e;return null===(e=V[null!=u?u:m])||void 0===e?void 0:e.address}),[u]),[g,y]=a.useState(""),[v,C]=a.useState(""),w=a.useMemo((()=>n.debounce((e=>C(e)),600)),[]),[j,T]=a.useState(null),[A,O]=a.useState(null),[B,S]=a.useState(!1),[R,I]=a.useState(!1),{toFiatPrice:N,fromFiatPrice:M}=Bt({chainId:u,toToken:A,fromToken:j}),_=We(),F=a.useMemo((()=>j?_(j):null),[j,_]),{getApprovalState:U,submitApprove:$,getPendingRest:z,getMaxBalance:q}=zt({account:p,chainId:u}),K=a.useMemo((()=>z(j)),[null==j?void 0:j.address,z]),{marginAmount:G}=function({fromToken:e,fromFiatPrice:t}){return{marginAmount:a.useMemo((()=>{var n;const o=t,s=null!==(n=null==e?void 0:e.decimals)&&void 0!==n?n:6,a=null!=o?new k.default(500).div(o):new k.default(0),r=P(a,s);return(r.lt(new k.default(1).times(new k.default(10).pow(s-3)))?new k.default(0):r).toString(10)}),[null==e?void 0:e.decimals,t])}}({fromToken:j,fromFiatPrice:M}),{resAmount:Y,priceImpact:X,executeSwap:Z,baseFeeAmount:Q,additionalFeeAmount:J,resPricePerToToken:ee,resPricePerFromToken:te,status:ne}=It({toToken:A,fromToken:j,marginAmount:G,fromAmount:v}),oe=a.useCallback((e=>{const t=e.toString();y(t),w(t)}),[y,w]);a.useEffect((()=>{u&&(O(null),T(null),oe("")),h&&h.chainId===u&&O(h),f&&f.chainId===u&&T(f)}),[h,f,u,oe]);const se=a.useCallback((()=>{T(A),O(j),oe("")}),[T,A,O,j,oe]),ae=a.useCallback((e=>oe(q(j))),[oe,q,j]),re=a.useMemo((()=>(100*Number(X)).toFixed(2)),[X]),ie=a.useMemo((()=>v&&M?new k.default(M).multipliedBy(v):null),[M,v]),ce=a.useMemo((()=>Y&&N?new k.default(N).multipliedBy(Y):null),[N,Y]),de=a.useMemo((()=>E.jsxs(o.Box,{sx:{display:"flex",fontWeight:600,typography:"body2",alignItems:"center",justifyContent:"center"},children:[E.jsx(Nt,{title:E.jsx(e.Trans,{id:"Due to the market condition, market price and estimated price may have a slight difference"}),mr:8}),E.jsxs(o.Box,{sx:{display:"flex"},children:[E.jsx(e.Trans,{id:"Current price impact"}),E.jsxs(o.Box,{sx:{color:l.palette.error.main,ml:4},children:[re,"%"]})]})]})),[re]),ue=a.useMemo((()=>E.jsx(Ut,{toToken:A,fromToken:j,priceStatus:ne,pricePerToToken:ee,pricePerFromToken:te})),[A,j,ne,ee,te]),pe=a.useMemo((()=>!H[u||1]),[u]),me=a.useMemo((()=>ne===Rt.Loading?E.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:E.jsxs(E.Fragment,{children:[E.jsx(o.RotatingIcon,{sx:{mr:5}}),E.jsx(e.Trans,{id:"Fetching best price..."})]})}):pe?E.jsxs(E.Fragment,{children:[E.jsx(o.Box,{component:i.Warn,sx:{mr:6,width:16,color:"warning.main"}}),E.jsx(e.Trans,{id:"Unsupported network - switch to trade"})]}):g&&new k.default(re).gt(15)?de:ue),[ne,ue,g,de,re,pe]),he=a.useMemo((()=>{const t=U(j,v),n=t===$t.Approving,s=t===$t.Insufficient&&!K,a=x?.1:.02,r=b===(null==j?void 0:j.address),i=new k.default(F||0);return p?d?E.jsx(o.Button,{fullWidth:!0,isLoading:!0,disabled:!0,children:E.jsx(e.Trans,{id:"Transaction Pending"})}):j&&A?s?E.jsx(o.Button,{fullWidth:!0,disabled:n,onClick:()=>$(j),children:n?E.jsx(e.Trans,{id:"Approving"}):E.jsx(e.Trans,{id:"Approve"})}):new k.default(v).gt(0)?ne===Rt.Loading?E.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-fetch-price-btn",children:E.jsx(e.Trans,{id:"Fetching Price..."})}):Y?i.lt(v)||r&&i.lte(a)?E.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-insufficient-balance-btn",children:E.jsx(e.Trans,{id:"Insufficient balance"})}):E.jsx(o.Button,{fullWidth:!0,onClick:()=>S(!0),"data-testid":"swap-review-btn",children:E.jsx(e.Trans,{id:"Review Swap"})}):E.jsx(o.Button,{fullWidth:!0,disabled:!0,children:E.jsx(e.Trans,{id:"Quote not available"})}):E.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-enter-amount-btn",children:E.jsx(e.Trans,{id:"Enter an amount"})}):E.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-select-token-btn",children:E.jsx(e.Trans,{id:"Select Tokens"})}):E.jsx(Ht,{})}),[x,p,v,A,Y,j,d,Z,K,$,ne,F,U,b]),fe=a.useMemo((()=>j&&A?E.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[E.jsx(Ve,{token:j,sx:{width:16,height:16,mr:6}}),`${v} ${j.symbol}`,E.jsx(o.Box,{component:i.DoubleRight,sx:{width:12,height:12,mx:16}}),E.jsx(Ve,{token:A,sx:{width:16,height:16,mr:6}}),`${D({input:Y,decimals:null==A?void 0:A.decimals})} ${A.symbol}`]}):E.jsx(o.Box,{})),[j,A,v,Y]);return E.jsxs(E.Fragment,{children:[E.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",typography:"caption",margin:20},children:[E.jsx(e.Trans,{id:"Swap"}),E.jsx(o.Box,{component:o.BaseButton,children:E.jsx(o.Box,{component:i.Setting,onClick:()=>I(!0),sx:{width:19,height:19,color:"text.primary",cursor:"pointer"}})})]}),E.jsxs(o.Box,{sx:{flex:1,padding:"0 20px 20px",overflowY:"auto"},children:[E.jsxs(o.Box,{children:[E.jsx(tt,{sx:{mb:4},token:j,amt:g,onMaxClick:ae,onInputChange:oe,showMaxBtn:!g,occupiedAddrs:[null!==(t=null==A?void 0:A.address)&&void 0!==t?t:""],fiatPriceTxt:ie?`$${L({input:ie,showDecimals:1})}`:"-",onTokenChange:(e,t)=>{if(t)return se();T(e),oe("")}}),E.jsx(Mt,{onClick:se}),E.jsx(tt,{token:A,amt:new k.default(g).gt(0)?D({input:Y,decimals:null==A?void 0:A.decimals}):"-",occupiedAddrs:[null!==(s=null==j?void 0:j.address)&&void 0!==s?s:""],fiatPriceTxt:ce?`$${L({input:ce,showDecimals:1})}(${re}%)`:"-",onTokenChange:(e,t)=>{if(t)return se();O(e)},readOnly:!0}),E.jsx(o.Box,{sx:{py:12,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexWrap:"wrap"},children:me})]}),he,E.jsxs(o.Box,{sx:{mt:13,display:"flex",typography:"h6",cursor:"pointer",justifyContent:"center",alignItems:"center",color:l.palette.text.disabled},onClick:()=>window.open("https://app.dodoex.io"),children:[E.jsx(o.Box,{sx:{width:24,typography:"body2",transform:"translate(1px, 2px)","& path":{fill:l.palette.text.disabled}},component:i.Dodo}),E.jsx(e.Trans,{id:"Powered by DODO protocol"})]})]}),E.jsx(_t,{toToken:A,fromToken:j,fromAmount:v,toAmount:Y,open:B,baseFeeAmount:Q,priceImpact:re,additionalFeeAmount:J,curToFiatPrice:ce,execute:()=>Z(fe),clearFromAmt:()=>oe(""),curFromFiatPrice:ie,pricePerFromToken:te,onClose:()=>S(!1)}),E.jsx(Ft,{open:R,onClose:()=>I(!1)})]})}exports.InitSwapWidget=function(e){const t=document.getElementById("dodo-swap-widget");A.createRoot(t).render(E.jsx(Dt,{...e,children:E.jsx(Vt,{})}))},exports.SwapWidget=function(e){return E.jsx(Dt,{...e,children:E.jsx(Vt,{})})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@lingui/react"),t=require("bignumber.js"),n=require("lodash"),o=require("@dodoex/components"),s=require("@ethersproject/address"),a=require("react"),i=require("react-redux"),r=require("@dodoex/icons"),l=require("identicon.js"),c=require("@web3-react/core"),d=require("@reduxjs/toolkit"),u=require("redux"),p=require("@ethersproject/contracts"),m=require("@ethersproject/constants"),h=require("@ethersproject/abi"),f=require("@web3-react/eip1193"),x=require("@web3-react/walletconnect"),g=require("@web3-react/metamask"),b=require("@ethersproject/providers"),y=require("@web3-react/types"),v=require("react/jsx-runtime"),E=require("@lingui/core"),C=require("react-window"),w=require("make-plural/plurals"),j=require("axios"),T=require("@ethersproject/bignumber"),A=require("react-dom/client");function O(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function B(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var k=O(t),S=B(a),R=O(l),I=O(j);function D({input:e,showDecimals:n=4,showPrecisionDecimals:o=2,showIntegerOnly:s=!1,showDecimalsOnly:a=!1,noGroupSeparator:i=!1}){const r=new t.BigNumber(e);if(r.isNaN())return"-";let l=r.dp(n,t.BigNumber.ROUND_DOWN);return l.eq(0)&&(r.gt(0)||r.lt(0))&&(l=r.sd(null!=o?o:n,t.BigNumber.ROUND_DOWN)),s&&(l=l.integerValue(t.BigNumber.ROUND_DOWN)),a&&(l=l.minus(l.integerValue(t.BigNumber.ROUND_DOWN))),i?l.toFormat({decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0}):l.toFormat()}function L({input:e,decimals:n,showPrecisionDecimals:o=2,noGroupSeparator:s}){if(null==e)return"-";const a=new t.BigNumber(e);if(a.isNaN())return"-";return D({input:a,showDecimals:void 0===n?0:n>6?6:n>4?4:n,showPrecisionDecimals:o,noGroupSeparator:s})}function N(e){if("number"==typeof e)return N(new t.BigNumber(e));if(e.isNaN())return"NaN";if(e.isNegative())return`-${N(e.negated())}`;if(e.isZero())return"0";let n=e.integerValue(t.BigNumber.ROUND_FLOOR),o=e.minus(n),s="";for(;!n.isZero();){s=n.modulo(10).toString().toString()+s,n=n.idiv(10)}if(""===s&&(s="0"),o.isZero())return s;s+=".";let a=0;for(;!o.isZero()&&a<100;){const e=o.times(10),n=e.integerValue(t.BigNumber.ROUND_FLOOR);s+=n.toString(),o=e.minus(n),a+=1}return s}const M=(e,n)=>{if("string"==typeof e&&!e.match(/[-+]?\d+(.+d+)?/))return e;const o=new t.BigNumber(e);if(n){let e=o.toFixed(n,t.BigNumber.ROUND_DOWN);return s=e,new t.BigNumber(s).isZero()&&(e=N(o.precision(n,t.BigNumber.ROUND_DOWN))),e}var s;return N(o)},_=(e,t)=>{let n=e;const o=n.match("[0-9。.]+");n=o&&o.length>0?o[0]:"",n=n.replace("。",".");let s=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&&(s=t[1].length),n=t.join(".")}return t>=0&&s>t?M(n,t):n},P=(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)};function F(e){try{return s.getAddress(e)}catch(e){return!1}}const U=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 W;!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"}(W||(W={}));const H={[W.MAINNET]:["https://rpc.ankr.com/eth","https://eth-mainnet.public.blastapi.io","https://eth-rpc.gateway.pokt.network","https://main-rpc.linkpool.io"],[W.RINKEBY]:["https://rinkeby-light.eth.linkpool.io/"],[W.GOERLI]:["https://goerli.optimism.io/"],[W.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"],[W.HECO]:["https://http-mainnet.hecochain.com","https://pub001.hg.network/rpc"],[W.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"],[W.ARBITRUM_ONE]:["https://arb1.arbitrum.io/rpc","https://rpc.ankr.com/arbitrum"],[W.ARBITRUM_RINKEBY]:["https://rinkeby.arbitrum.io/rpc"],[W.AURORA]:["https://mainnet.aurora.dev/"],[W.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"],[W.OKCHAIN]:["https://exchainrpc.okex.org","https://okc-mainnet.gateway.pokt.network/v1/lb/6275309bea1b320039c893ff"],[W.OPTIMISM]:["https://mainnet.optimism.io","https://optimism-mainnet.public.blastapi.io"],[W.BOBA]:["https://mainnet.boba.network","https://boba-mainnet.gateway.pokt.network/v1/lb/623ad21b20354900396fed7f","https://lightning-replica.boba.network"],[W.AVALANCHE]:["https://api.avax.network/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://ava-mainnet.public.blastapi.io/ext/bc/C/rpc"],[W.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"]},$={symbol:"ETH",address:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",name:"Ether",decimals:18,showDecimals:4,wrappedTokenSymbol:"WETH"},z={[W.MAINNET]:Object.assign(Object.assign({},$),{wrappedTokenAddress:"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}),[W.RINKEBY]:Object.assign(Object.assign({},$),{wrappedTokenAddress:"0xB26c0d8Be2960c70641A95A9195BE1f59Ac83aC0"}),[W.GOERLI]:Object.assign(Object.assign({},$),{wrappedTokenAddress:"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6"}),[W.OPTIMISM]:Object.assign(Object.assign({},$),{wrappedTokenAddress:"0x4200000000000000000000000000000000000006"}),[W.CRONOS]:Object.assign(Object.assign({},$),{symbol:"CRO",name:"Cronos",wrappedTokenSymbol:"WCRO",wrappedTokenAddress:"0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23"}),[W.BOBA]:Object.assign(Object.assign({},$),{wrappedTokenAddress:"0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000"}),[W.BSC]:Object.assign(Object.assign({},$),{symbol:"BNB",name:"BNB",wrappedTokenSymbol:"WBNB",wrappedTokenAddress:"0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"}),[W.OKCHAIN]:Object.assign(Object.assign({},$),{symbol:"OKT",name:"OKT",wrappedTokenSymbol:"WOKT",wrappedTokenAddress:"0x8F8526dbfd6E38E3D8307702cA8469Bae6C56C15"}),[W.HECO]:Object.assign(Object.assign({},$),{symbol:"HT",name:"HT",showDecimals:6,wrappedTokenSymbol:"WHT",wrappedTokenAddress:"0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f"}),[W.POLYGON]:Object.assign(Object.assign({},$),{symbol:"MATIC",name:"MATIC",showDecimals:6,wrappedTokenSymbol:"WMATIC",wrappedTokenAddress:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"}),[W.MOONRIVER]:Object.assign(Object.assign({},$),{symbol:"MOVR",name:"MOVR",showDecimals:6,wrappedTokenSymbol:"WMOVR",wrappedTokenAddress:"0x98878b06940ae243284ca214f92bb71a2b032b8a"}),[W.ARBITRUM_ONE]:Object.assign(Object.assign({},$),{name:"Ethereum",showDecimals:6,wrappedTokenAddress:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"}),[W.ARBITRUM_RINKEBY]:Object.assign(Object.assign({},$),{name:"Ether",showDecimals:6,wrappedTokenAddress:"0xEBbc3452Cc911591e4F18f3b36727Df45d6bd1f9"}),[W.AURORA]:Object.assign(Object.assign({},$),{name:"Ethereum",showDecimals:6,wrappedTokenAddress:"0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB"}),[W.AVALANCHE]:Object.assign(Object.assign({},$),{symbol:"AVAX",name:"Avalanche",showDecimals:6,wrappedTokenSymbol:"WAVAX",wrappedTokenAddress:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7"})},V={[W.MAINNET]:"ethereum",[W.RINKEBY]:"rinkeby",[W.GOERLI]:"goerli",[W.OPTIMISM]:"optimism",[W.CRONOS]:"cronos",[W.BOBA]:"boba",[W.BSC]:"bsc",[W.OKCHAIN]:"okex-chain",[W.HECO]:"heco",[W.POLYGON]:"polygon",[W.MOONRIVER]:"moonriver",[W.ARBITRUM_ONE]:"arbitrum",[W.ARBITRUM_RINKEBY]:"arb-rinkeby",[W.AURORA]:"aurora",[W.AVALANCHE]:"avalanche"},q={[W.MAINNET]:"etherscan.io",[W.RINKEBY]:"rinkeby.etherscan.io",[W.GOERLI]:"goerli.etherscan.io",[W.OPTIMISM]:"optimistic.etherscan.io",[W.CRONOS]:"cronoscan.com",[W.BOBA]:"blockexplorer.boba.network",[W.BSC]:"bscscan.com",[W.OKCHAIN]:"www.oklink.com/okexchain",[W.HECO]:"hecoinfo.com",[W.POLYGON]:"polygonscan.com",[W.MOONRIVER]:"moonriver.moonscan.io",[W.ARBITRUM_ONE]:"arbiscan.io",[W.ARBITRUM_RINKEBY]:"testnet.arbiscan.io",[W.AURORA]:"aurorascan.dev",[W.AVALANCHE]:"snowtrace.io"};function K(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 s=0;for(o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(n[o[s]]=e[o[s]])}return n}function G(e,t,n,o){return new(n||(n=Promise))((function(s,a){function i(e){try{l(o.next(e))}catch(e){a(e)}}function r(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,r)}l((o=o.apply(e,t||[])).next())}))}const Y={colorMode:"dark",slippage:3..toString(),ddl:20};var X=(e=Y,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 Z={chainId:W.MAINNET,latestBlockNumber:0};var Q=(e=Z,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 J={tokenList:[],popularTokenList:[],ethBalance:void 0,accountBalances:{},balanceLoadings:{},slippageWithTokens:[]};var ee,te=(e=J,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"}(ee||(ee={}));const ne={height:void 0,width:void 0,apikey:"",feeRate:0,rebateTo:"",isReverseRouting:!1,contractStatus:ee.Initial};var oe=(e=ne,t)=>"SET_GLOBAL_PROPS"===t.type?Object.assign(Object.assign({},e),t.payload):e;const se={settings:Y,wallet:Z,globals:ne,token:J},ae=u.combineReducers({settings:X,wallet:Q,token:te,globals:oe}),ie=d.configureStore({reducer:ae,middleware:e=>e({serializableCheck:{ignoredActions:["SET_ACCOUNT_BALANCES","SET_ETH_BALANCE"],ignoredPaths:["token.accountBalances","token.ethBalance"]}}),preloadedState:se}),re=e=>(null!=e?e:ie.getState()).wallet.chainId,le=e=>(null!=e?e:ie.getState()).wallet.latestBlockNumber,ce=e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_ACCOUNT_BALANCES",payload:e})})),de=e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_BALANCE_LOADINGS",payload:e})}));var ue=[{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"}],pe={[W.MAINNET]:{MULTI_CALL:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",DODO_APPROVE:"0xCB859eA579b28e02B87A1FDE08d087ab9dbE5149",ERC20_HELPER:"0xD9ef2d1583e8Aa196123e773BE38B539a4d149df"},[W.RINKEBY]:{MULTI_CALL:"0xb7E1C577f95959a3eD11f9281702850328b4e0e4",DODO_APPROVE:"0xcC8d87A7C747eeE4242045C47Ef25e0A81D56ae3",ERC20_HELPER:"0x6A42091d713A67E25a1D11aeE14E7AEB96E0331f"},[W.GOERLI]:{MULTI_CALL:"0x696E25A5e2AEd1C55E6d6Cfa0532Bbda9020165d",DODO_APPROVE:"0xC9143e54021f4a6d33b9b89DBB9F458AaEdd56FB",ERC20_HELPER:"0x24549FC74B3076A962624A26370ed556c467F74C"},[W.BSC]:{MULTI_CALL:"0x1Ee38d535d541c55C9dae27B12edf090C608E6Fb",DODO_APPROVE:"0xa128Ba44B2738A558A1fdC06d6303d52D3Cef8c1",ERC20_HELPER:"0x566651Ad34f6306872FaC5fB95bbF4C9beE8D8F2"},[W.HECO]:{MULTI_CALL:"0x76a328B3440B9276a31523e731B34082df7a6f1A",DODO_APPROVE:"0x68b6c06Ac8Aa359868393724d25D871921E97293",ERC20_HELPER:"0x270C2abC692Dd476B860CCbDfD6D8146BF61f8D8"},[W.POLYGON]:{MULTI_CALL:"0xc9eD9B18e447e600238fe50e944B9062B664DEa4",DODO_APPROVE:"0x292E6b2e054e1157df71C1C9510265CA8C0c7672",ERC20_HELPER:"0xfd24312Ec7871A6D1a31e454D5AbB16c6c25a9b3"},[W.ARBITRUM_ONE]:{MULTI_CALL:"0xF718F2bd590E5621e53f7b89398e52f7Acced8ca",DODO_APPROVE:"0xA867241cDC8d3b0C07C85cC06F25a0cD3b5474d8",ERC20_HELPER:"0x7C062B9C584fA6eC2504270790D38240A2c5fE72"},[W.ARBITRUM_RINKEBY]:{MULTI_CALL:"0x696E25A5e2AEd1C55E6d6Cfa0532Bbda9020165d",DODO_APPROVE:"0x5BaF16d57620Cb361F622232F3cb4090e35F3da2",ERC20_HELPER:"0x5B2fd46E6E3Ff1E479d651ec0b210882Aa9871dF"},[W.AURORA]:{MULTI_CALL:"0x989DcAA95801C527C5B73AA65d3962dF9aCe1b0C",DODO_APPROVE:"0x335aC99bb3E51BDbF22025f092Ebc1Cf2c5cC619",ERC20_HELPER:"0xE8C9A78725D0451FA19878D5f8A3dC0D55FECF25"},[W.MOONRIVER]:{MULTI_CALL:"0x2ff2CeE6E9359F9eA1cF2f51d18bF9F2045447E4",DODO_APPROVE:"0xE8C9A78725D0451FA19878D5f8A3dC0D55FECF25",ERC20_HELPER:"0x6373ceB657C83C91088d328622573FB766064Ac4"},[W.OKCHAIN]:{MULTI_CALL:"0x5e84190a270333aCe5B9202a3F4ceBf11b81bB01",DODO_APPROVE:"0x7737fd30535c69545deeEa54AB8Dd590ccaEBD3c",ERC20_HELPER:"0x4775b1858f1e417C9609D455C3Ad8751ec01daC4"},[W.OPTIMISM]:{MULTI_CALL:"0xb98Ac2fEFc8b73aeAE33D02BB00c26E12afCa9Df",DODO_APPROVE:"0xa492d6eABcdc3E204676f15B950bBdD448080364",ERC20_HELPER:"0x42E456ea0dd7538ea103fBb1d0388D14C97bB5b2"},[W.BOBA]:{MULTI_CALL:"0xD56281EF996B6B29874C77D2e1464216E8043127",DODO_APPROVE:"0x8F8Dd7DB1bDA5eD3da8C9daf3bfa471c12d58486",ERC20_HELPER:"0x9FCFD9ff955D36856F8EE480471B05488C0eB5cA"},[W.AVALANCHE]:{MULTI_CALL:"0x97f0153E7F5749640aDF3Ff9CFC518b79D6Fe53b",DODO_APPROVE:"0xCFea63e3DE31De53D68780Dd65675F169439e470",ERC20_HELPER:"0xC3528D128CC227fd60793007b5e3FdF7c2945282"},[W.CRONOS]:{MULTI_CALL:"0x4f4408D78F9E9e242c17C635FbD0f1952951c917",DODO_APPROVE:"0x9B736bB8f336f61E16454DCA4dE130703D151042",ERC20_HELPER:"0xbd2F5c60cf7d60daD2106ceD4D21b90722761f14"}};function me(e,t,...n){return G(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 s=yield function(e,t,n){return G(this,void 0,void 0,(function*(){const o=yield he(e,t,n),s=new Map;for(const{req:e,resp:t}of o)s.set(e,t);return e.map((e=>({req:e,resp:s.get(e)})))}))}(o,e,t),a=new Map;for(const{req:e,resp:t}of s)a.set(e,null==t?void 0:t.result);return n.map((e=>e.filter((e=>!e.callData||a.get(e.callData))).map(((e,t)=>e.processor(e.callData?a.get(e.callData):null,t)))))}))}function he(e,t,o){return G(this,void 0,void 0,(function*(){let s=[e];e.length>800&&(s=n.chunk(e,800));let a=[];const i=s.map((e=>G(this,void 0,void 0,(function*(){const n=e.map((e=>[e.to,e.data])),s={data:t.interface.encodeFunctionData("aggregate",[n]),to:o};let i;try{i=yield t.provider.call(s)}catch(n){const s=e.length;if(s>20){const n=Math.floor(s/2),[i,r]=yield Promise.all([he(e.slice(0,n),t,o),he(e.slice(n,s),t,o)]);a=[...a,...i,...r]}else{const e="[sendCallReqs] error";console.error(e,n)}}if(void 0===i)throw new Error("Unexpected batch result");const[r,l]=h.defaultAbiCoder.decode(["uint256","bytes[]"],i);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(i)).filter((e=>"fulfilled"===e.status)).forEach((({value:e})=>{a=[...a,...e]})),a}))}function fe(e,t,n,o){if(!F(e)||e===m.AddressZero)throw Error(`Invalid 'address' parameter '${e}'.`);return new p.Contract(e,t,function(e,t){return t?function(e,t){return e.getSigner(t).connectUnchecked()}(e,t):e}(n,o))}function xe(){const{provider:e,account:t,chainId:n}=c.useWeb3React(),[o,s]=a.useState(!1),i=a.useMemo((()=>pe[n]),[n]),r=a.useCallback(((n,o)=>{if(e)return fe(n,o,e,t)}),[e,t]),l=a.useCallback((e=>{if(!i)return;const{MULTI_CALL:t}=i,n=r(t,ue);return(()=>G(this,void 0,void 0,(function*(){if(n){s(!0);try{const[o]=yield me(n,t,e);return o}catch(e){console.error("Contract: useMultiContract is error",e)}s(!1)}})))()}),[i,r]);return{getContract:r,contractConfig:i,call:l,loading:o}}var ge=[{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 be(){const{provider:e,account:t}=c.useWeb3React(),n=i.useDispatch(),o=i.useSelector(le);a.useEffect((()=>{(()=>{G(this,void 0,void 0,(function*(){if(!e||!t)return;const o=yield e.getBalance(t);n((e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_ETH_BALANCE",payload:e})})))(new k.default(o.toString()).div(1e18)))}))})()}),[e,t,n,o])}function ye(){const{provider:e,chainId:t}=c.useWeb3React(),n=i.useDispatch();a.useEffect((()=>{const o=e=>{n((e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_BLOCK_NUMBER",payload:e})})))(e))};return(()=>{G(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 ve(e){return Number.parseInt(e,16)}class Ee extends y.Connector{constructor(e,t){super(e),this.customProvider=t,t.on("connect",(({chainId:e})=>{this.actions.update({chainId:ve(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:ve(e)})})).on("accountsChanged",(e=>{this.actions.update({accounts:e})}))}activate(){return G(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 Ce([e,t]){return[e,t]}var we;function je(){return je=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},je.apply(this,arguments)}var Te,Ae;function Oe(){return Oe=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},Oe.apply(this,arguments)}var Be;!function(e){e.INTEGRATOR="integrator",e.METAMASK="metamask",e.WALLET_CONNECT="walletConnect"}(Be||(Be={}));const ke={[Be.METAMASK]:{name:"MetaMask",type:Be.METAMASK,icon:function(e){return S.createElement("svg",je({height:355,viewBox:"0 0 397 355",width:397,xmlns:"http://www.w3.org/2000/svg"},e),we||(we=S.createElement("g",{fill:"none",fillRule:"evenodd",transform:"translate(-1 -1)"},S.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"}),S.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)"}),S.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"}),S.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"}),S.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"}),S.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),S.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),S.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"}),S.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 56.25-39.305949z",fill:"#eb8f35"}),S.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),S.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),S.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),S.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),S.createElement("path",{d:"m114.622644 327.195472 56.25-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3"}),S.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)"}),S.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)"}),S.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),S.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"}),S.createElement("g",{transform:"matrix(-1 0 0 1 399.056611 0)"},S.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"}),S.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),S.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),S.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"}),S.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 55.18868-38.243626z",fill:"#eb8f35"}),S.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),S.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),S.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),S.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),S.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)"}),S.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),S.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"},[Be.WALLET_CONNECT]:{name:"WalletConnect",type:Be.WALLET_CONNECT,icon:function(e){return S.createElement("svg",Oe({height:512,viewBox:"0 0 512 512",width:512,xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),Te||(Te=S.createElement("radialGradient",{id:"a",cx:"0%",cy:"50%",r:"100%"},S.createElement("stop",{offset:0,stopColor:"#5d9df6"}),S.createElement("stop",{offset:1,stopColor:"#006fff"}))),Ae||(Ae=S.createElement("g",{fill:"none",fillRule:"evenodd"},S.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)"}),S.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)"}))))}}},Se={};function Re({provider:e,jsonRpcUrlMap:t,defaultChainId:n}){const o=console.error,s=a.useMemo((()=>function(e,t){if(t){if(b.JsonRpcProvider.isProvider(t))return Ce(c.initializeConnector((e=>new Ee(e,t))));if(b.JsonRpcProvider.isProvider(t.provider))throw new Error("Eip1193Bridge is experimental: pass your ethers Provider directly");return Ce(c.initializeConnector((n=>new f.EIP1193({actions:n,provider:t,onError:e}))))}}(o,e)),[o,e]),i=a.useMemo((()=>function(e){return Ce(c.initializeConnector((t=>new g.MetaMask({actions:t,onError:e}))))}(o)),[o]),r=a.useMemo((()=>t?Object.assign(Object.assign({},H),t):H),[t]),l=a.useMemo((()=>function(e,t,n,o){return Ce(c.initializeConnector((s=>new x.WalletConnect({actions:s,options:{rpc:t,qrcode:e},onError:o,defaultChainId:n}))))}(!0,r,n,o)),[r,n,o]);return s&&(Se[Be.INTEGRATOR]=s),Se[Be.METAMASK]=i,Se[Be.WALLET_CONNECT]=l,Object.values(Se)}function Ie(){const{chainId:e}=c.useWeb3React(),t=i.useSelector(re);return a.useMemo((()=>e||t||1),[e,t])}function De({tokenList:e,popularTokenList:t}){const o=i.useDispatch(),[s,r]=a.useState([]),{account:l}=c.useWeb3React(),d=Ie(),u=i.useSelector(le),p=a.useMemo((()=>(null==t?void 0:t.filter((e=>e.chainId===d)))||[]),[t,d]),m=a.useMemo((()=>{const e=s.map((({address:e})=>e));return null==t||t.forEach((({address:t})=>{e.includes(t)||e.push(t)})),e}),[s,t]);!function({tokenList:e,addresses:t,blockNumber:n}){const{account:o}=c.useWeb3React(),s=i.useDispatch(),r=a.useMemo((()=>[...(null==e?void 0:e.map((e=>e.address)))||[],...t||[]].map((e=>e.toLocaleLowerCase()))),[e,t]),{getContract:l,contractConfig:d,call:u}=xe(),[p,m]=a.useState(),f=a.useMemo((()=>{if(!o||!r.length||!d)return;const{DODO_APPROVE:e,ERC20_HELPER:t}=d,n=l(t,ge);if(!n)return;let a={};const i=r.map((s=>(a[s]=!0,{callData:{data:n.interface.encodeFunctionData("isERC20",[s,o,e]),to:t},processor:e=>{const t=new h.Interface(ge).decodeFunctionResult("isERC20",e),{balance:n,isOk:o}=t,a=parseInt(t.decimals),i=new k.default(10).pow(a),r=new k.default(t.allownance.toString()).div(i);return o?{address:s,decimals:a,symbol:t.symbol,name:t.name,balance:new k.default(n.toString()).div(i),allowance:r}:{address:s,balance:new k.default(0),allowance:new k.default(0)}}})));return s(de(a)),i}),[o,l,JSON.stringify(r)]);a.useEffect((()=>{(()=>{G(this,void 0,void 0,(function*(){if(!f)return;const e=yield u(f),t={};e&&(e.forEach((e=>{t[e.address.toLocaleLowerCase()]={tokenBalances:e.balance,tokenAllowances:e.allowance}})),s(ce(t))),m(e);let n={};r.forEach((e=>{n[e]=!1})),s(de(n))}))})()}),[f,n])}({addresses:m,blockNumber:u}),a.useEffect((()=>{(()=>{G(this,void 0,void 0,(function*(){let t=[];if(e)t=e;else{const e=yield Promise.resolve().then((function(){return require("./tokenList-ee5e15c8.cjs")}));t=n.unionBy(e.default,p,"address")}const s=d,a=t.filter((e=>e.chainId===s));r(a),o((e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_TOKEN_LIST",payload:e})})))(a))}))})()}),[e,o,d,p]),a.useEffect((()=>{o(ce({}))}),[l,d]),a.useEffect((()=>{o((e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_POPULAR_TOKEN_LIST",payload:e})})))(p))}),[p,o])}const Le=e=>(null!=e?e:ie.getState()).token.tokenList,Ne=e=>(null!=e?e:ie.getState()).token.accountBalances,Me=e=>(null!=e?e:ie.getState()).token.ethBalance||new k.default(NaN),_e=e=>(null!=e?e:ie.getState()).token.defaultFromToken,Pe=e=>(null!=e?e:ie.getState()).token.defaultToToken,Fe=e=>(null!=e?e:ie.getState()).token.balanceLoadings;function Ue(){const{account:e,chainId:t}=c.useWeb3React(),n=i.useSelector(Ne),o=i.useSelector(Me),s=a.useMemo((()=>z[t||1]),[t]),r=a.useCallback((t=>{var a;if(!e)return null;if(t.symbol===s.symbol&&P(t.address,s.address))return!o||(null==o?void 0:o.isNaN())?null:o;const i=null===(a=n[t.address.toLocaleLowerCase()])||void 0===a?void 0:a.tokenBalances;return!i||(null==i?void 0:i.isNaN())?null:i}),[n,o,e]);return r}var We;function He(e,t,n,o=0){if(n&&(e=e.toLocaleLowerCase(),t=t.toLocaleLowerCase()),e===t)return We.fully+o;const s=e.indexOf(t);return 0===s?We.prefix+o:s>0?We.other+o:We.none}!function(e){e[e.fully=1]="fully",e[e.prefix=2]="prefix",e[e.other=3]="other",e[e.none=0]="none"}(We||(We={}));function $e({value:e,onChange:t,occupiedAddrs:n,hiddenAddrs:o,showAddrs:s}){const[r,l]=a.useState(""),c=i.useSelector(Le),d=Ie(),u=Ue(),p=a.useMemo((()=>new Set(o?o.map((e=>e.toLowerCase())):void 0)),[o]),m=a.useMemo((()=>s?new Set(s.map((e=>e.toLowerCase()))):void 0),[s]),h=a.useCallback((e=>e.filter((e=>{if(e.chainId!==d)return!1;let t=!0;return t=m?m.has(e.address.toLowerCase()):!p.has(e.address.toLowerCase()),t}))),[m,d,p]),f=a.useCallback((t=>{if(null===t)return null;const o=[];r?t.forEach((e=>{const t=((e,t,{matchAddress:n}={})=>{if(!t)return 0;const o=t.toLocaleLowerCase();let s=0;n&&e.address.toLocaleLowerCase()===o&&(s=1),s||(s=He(e.symbol.toLocaleLowerCase(),o,!1,1));if(s)e.name.toLocaleLowerCase()===o&&(s=We.fully+1);else{let t=He(e.name.toLocaleLowerCase(),o,!1,10);t=t===We.fully+10?We.fully+1:t,s=t}return s})(e,r,{matchAddress:!0});t&&o.push({sort:t,token:e})})):t.forEach((e=>{o.push({sort:0,token:e})}));const s=[];return o.sort(((t,o)=>{const s=t.token,a=o.token;if(e){if(s.address===e.address)return-1;if(a.address===e.address)return 1}if(null==n?void 0:n.includes(s.address))return-1;if(null==n?void 0:n.includes(a.address))return 1;const i=u&&u(s)||new k.default(0),r=u&&u(a)||new k.default(0);return i.eq(r)?t.sort!==o.sort?t.sort>o.sort?1:-1:s.symbol.localeCompare(a.symbol):i.gt(r)?-1:1})).some((e=>!!(r&&s.length>21)||(s.push(e.token),!1))),s}),[r,u,n,e]),x=a.useCallback((e=>{const o=e.address.toLowerCase();t(e,!!(null==n?void 0:n.some((e=>e.toLowerCase()===o))))}),[t,n]),g=a.useMemo((()=>{const e=h(c);return f(e)||[]}),[c,h,f]);return{filter:r,setFilter:l,showTokenList:g,onSelectToken:x}}function ze({width:e=24,height:t=24,marginRight:n=8,url:s,zIndex:r,cross:l,address:d,token:u,sx:p}){const[m,h]=a.useState(!1),[f,x]=a.useState(""),[g,b]=a.useState(""),[y,E]=a.useState(!1),C=a.useCallback((()=>h(!0)),[]);let w=function(e){const t=i.useSelector(Le),{chainId:n}=c.useWeb3React();return a.useMemo((()=>{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])}(d);u&&(w=u);const j=d||(null==w?void 0:w.address),T=null==w?void 0:w.symbol,A=null==T?void 0:T.charAt(0).toUpperCase(),O=a.useMemo((()=>{const e=null==w?void 0:w.logoURI;return s||e||""}),[s,w]);return a.useEffect((()=>{E(!1)}),[j,O]),a.useEffect((()=>{l&&(O?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()}}(O,(e=>{x(e)})):x(""))}),[O,l]),a.useEffect((()=>{try{let t=j;if(t&&t.length<15&&(t=t.padEnd(15,"0")),t){const n=new R.default(t,{size:e,format:"svg",margin:.2,background:[255,234,4,255]}).toString();b(`data:image/svg+xml;base64,${n}`)}}catch(e){console.error("generate Identicon error: ",e)}}),[j,e]),v.jsxs(o.Box,{sx:Object.assign({position:"relative",display:"flex",alignItems:"center",justifyContent:"center",minWidth:e,width:e,height:t,marginRight:n,zIndex:r},p||{}),style:{width:e,height:t},children:[!m&&v.jsx(o.Box,{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:A}),v.jsx(o.Box,{component:"img",src:!(l?f:O)||y?g:l?f:O,onLoad:C,onError:e=>{const t=e.target;j&&g&&E(!0),t.onerror=null},sx:{position:"absolute",top:"0",bottom:"0",left:"0",right:"0",borderRadius:"50%",overflow:"hidden",width:"100%",height:"100%"}})]})}function Ve({token:t,onClick:n}){var s,a;const i=o.useTheme();return v.jsxs(o.Box,{component:o.BaseButton,sx:{display:"flex",alignItems:"center",color:i.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)?v.jsxs(v.Fragment,{children:[v.jsx(ze,{url:null==t?void 0:t.logoURI,address:null!==(s=null==t?void 0:t.address)&&void 0!==s?s:"",marginRight:6}),v.jsx(o.Box,{children:null!==(a=null==t?void 0:t.symbol)&&void 0!==a?a:"-"})]}):v.jsx(e.Trans,{id:"SELECT TOKEN"}),v.jsx(o.Box,{sx:{ml:7,width:12,transform:"rotateX(180deg)"},component:r.CaretUp})]})}function qe({onClick:t,balance:n,decimals:s,address:a,showMaxBtn:i}){const{palette:r}=o.useTheme();return v.jsxs(o.Box,{sx:{display:"flex",typography:"body2",color:r.text.secondary},children:[v.jsx(e.Trans,{id:"Balance:"})," ",a?L({input:n,decimals:Math.min(s||4,4)}):"-",i&&n&&n.gt(0)&&v.jsx(o.Box,{component:o.BaseButton,sx:{ml:6,color:(null==n?void 0:n.gt(0))?r.primary.main:r.text.disabled,cursor:a&&t?"pointer":"unset"},onClick:()=>t&&t(n?n.toString():""),children:v.jsx(e.Trans,{id:"Max"})})]})}function Ke({readOnly:e,sx:t,value:n,decimals:s,onChange:i,suffix:l,withClear:c,onFocus:d,placeholder:u}){const p=o.useTheme(),m=a.useMemo((()=>l||(c&&n&&i?v.jsx(o.Box,{component:o.BaseButton,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},onClick:()=>{i&&i("")},children:v.jsx(o.Box,{component:r.Error,sx:{width:12,color:"text.primary"}})}):void 0)),[i,l,p.palette.text.primary,n,c]);return v.jsxs(o.Box,{sx:Object.assign({mt:12,display:"flex",justifyContent:"space-between",alignItems:"center"},t),"data-testid":"number-input-wrapper",children:[v.jsx(o.Input,{fullWidth:!0,value:n,readOnly:e,placeholder:u||"0.00",onFocus:d,onChange:e=>{const t=e.target.value,n=0===t.length?"":_(t,s);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 Ge({open:e,onClose:t,title:n,rightSlot:s,canBack:a=!0,children:i,height:l,testId:c}){return v.jsxs(o.Box,{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:l},"data-testid":c,"data-active":e?"1":"0",children:[n?v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:20},children:[v.jsx(o.Box,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:n}),s,!s&&a&&v.jsx(o.Box,{component:r.Error,sx:{color:"text.secondary",cursor:"pointer"},onClick:t})]}):"",i]})}const Ye=e=>(null!=e?e:ie.getState()).globals;function Xe({token:e,disabled:t,onClick:n}){return v.jsxs(o.Box,{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:[v.jsx(ze,{token:e}),e.symbol]})}function Ze({token:e,disabled:t,style:n,onClick:s}){const a=Ue()(e),i=a?D({input:a}):"";return v.jsxs(o.Box,{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||s()},"data-testid":"token-picker-item",children:[v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[v.jsx(ze,{token:e}),v.jsxs(o.Box,{children:[v.jsx(o.Box,{sx:{fontWeight:600,textAlign:"left"},children:e.symbol}),v.jsx(o.Box,{sx:{mt:4,textAlign:"left"},children:i})]})]}),v.jsx(o.Box,{sx:{color:"text.secondary"},children:e.name})]})}function Qe({value:e,onChange:t,occupiedAddrs:n,hiddenAddrs:s,showAddrs:r,visible:l}){var c;const d=Ie(),u=i.useSelector((e=>((e,t)=>(null!=t?t:ie.getState()).token.popularTokenList.filter((({chainId:t})=>e===t)))(d,e))),{showTokenList:p,filter:m,setFilter:h,onSelectToken:f}=$e({value:e,onChange:t,occupiedAddrs:n,hiddenAddrs:s,showAddrs:r}),x=a.useRef(null),g=a.useRef(null),[b,y]=a.useState(0);a.useEffect((()=>{l&&x.current&&y(x.current.offsetHeight-34)}),[x,l]);const w=a.useCallback((({index:t,style:n})=>{const s=!!(null==u?void 0:u.length);if(0===t&&s)return v.jsx(o.Box,{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:u.map((t=>v.jsx(Xe,{token:t,disabled:(null==e?void 0:e.address)===t.address,onClick:()=>f(t)},t.address)))});const a=p[s?t-1:t];return v.jsx(Ze,{token:a,disabled:!!e&&e.address===a.address,style:n,onClick:()=>f(a)})}),[p,u,g,e]),j=a.useCallback((e=>{var t;if(0===e&&(null==u?void 0:u.length)){const e=(null===(t=g.current)||void 0===t?void 0:t.offsetHeight)||0;return e<=52?0:e}return 52}),[g,u]);return v.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",px:20,flex:1},children:[v.jsx(o.SearchInput,{fullWidth:!0,height:48,value:m,onChange:e=>h(e.target.value),clearValue:()=>h(""),placeholder:E.i18n._("Enter the token symbol or address")}),v.jsx(o.Box,{sx:{mt:16,pb:16,flex:1,minHeight:64},ref:x,children:v.jsx(C.VariableSizeList,{height:b,itemCount:p.length+((null==u?void 0:u.length)?1:0),itemSize:j,width:"100%",className:"token-list",children:w},null===(c=g.current)||void 0===c?void 0:c.offsetHeight)})]})}function Je({open:t,value:n,onClose:o,occupiedAddrs:s,onTokenChange:a}){const{height:r}=i.useSelector(Ye);return v.jsx(Ge,{height:r,open:t,onClose:o,title:v.jsx(e.Trans,{id:"Select a token"}),testId:"token-picker-wrapper",children:v.jsx(Qe,{value:n,visible:t,onChange:a,occupiedAddrs:s})})}function et({sx:e,amt:t,token:n,readOnly:s,showMaxBtn:i,onMaxClick:r,fiatPriceTxt:l,occupiedAddrs:c,onInputFocus:d,onTokenClick:u,onInputChange:p,onTokenChange:m}){const h=o.useTheme(),f=Ue(),[x,g]=a.useState(!1),b=n?f(n):null;return v.jsxs(o.Box,{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:[v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[v.jsx(Ve,{token:n,onClick:()=>g(!0)}),v.jsx(qe,{balance:b,onClick:r,showMaxBtn:i,address:null==n?void 0:n.address,decimals:null==n?void 0:n.decimals})]}),v.jsx(Ke,{value:t,onFocus:d,onChange:p,readOnly:s,withClear:!0}),v.jsx(o.Box,{sx:{mt:4,typography:"body2",color:h.palette.text.secondary},children:l}),v.jsx(Je,{value:n,open:x,occupiedAddrs:c,onClose:()=>{u&&u(),g(!1)},onTokenChange:(e,t)=>{m(e,t),g(!1)}})]})}const tt={"en-US":w.en,"zh-CN":w.zh,pseudo:w.en};function nt({locale:t,children:n}){return a.useEffect((()=>{(()=>{G(this,void 0,void 0,(function*(){yield function(e="en-US"){return G(this,void 0,void 0,(function*(){E.i18n.loadLocaleData(e,{plurals:()=>tt[e]});try{const n=yield(t=`./locales/${e}.js`,Promise.resolve().then((function(){return B(require(t))})));E.i18n.load(e,n.messages||n.default.messages)}catch(e){}var t;E.i18n.activate(e)}))}(t)}))})()}),[t]),v.jsx(e.I18nProvider,{i18n:E.i18n,children:n})}var ot,st,at;!function(e){e[e.Running=0]="Running",e[e.Success=1]="Success",e[e.Failed=2]="Failed",e[e.Warning=3]="Warning"}(ot||(ot={})),function(e){e.Canceled="canceled",e.Failed="failed",e.Success="success",e.Submitted="submitted"}(st||(st={})),function(e){e[e.Failed=0]="Failed",e[e.Success=1]="Success"}(at||(at={}));var it,rt=[{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"}(it||(it={}));const lt=(e,t)=>G(void 0,void 0,void 0,(function*(){const{value:n,from:o,to:s,data:a}=e,i={from:o,to:s,value:n,data:a};n&&!/^0x0*$/.test(n)||delete i.value;try{return(yield t.estimateGas(i)).add(5e4)}catch(e){t.call(i).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})),ct=(e,t)=>G(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(E.i18n._("Transaction rejected.")):e}}));var dt,ut;!function(e){e.Approval="APPROVAL",e.TX="TX",e.TypedSign="TypedSign"}(dt||(dt={})),function(e){e.Normal="Normal",e.Privacy="Privacy",e.LimitOrder="LimitOrder",e.RFQ="RFQ"}(ut||(ut={}));const pt=new k.default(2).pow(256).minus(1),mt=e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_GLOBAL_PROPS",payload:e})}));function ht({onTxFail:e,onTxSubmit:t,onTxSuccess:n}={}){const{account:o,provider:s}=c.useWeb3React(),r=Ie(),[l,d]=a.useState(!1),[u,p]=a.useState(new Map),m=i.useDispatch(),[h,f]=a.useState(null),[x,g]=a.useState(""),[b,y]=a.useState(null),[v,C]=a.useState(!1),[w,j]=a.useState(),T=a.useCallback(((a,i,l,c=!1,u,h,x,b)=>G(this,void 0,void 0,(function*(){if(g(""),f(""),!o||!s)throw new Error("Submission: Cannot execute step when the wallet is disconnected");let v,w,T;j((()=>x)),d(!1);try{if(d(!0),i.opcode===dt.Approval)T=yield((e,t,n,o,s,a)=>G(void 0,void 0,void 0,(function*(){const i=fe(e,rt,s,a).interface.encodeFunctionData("approve",[n,o.toFixed()]),r={from:t,to:e,data:i,value:`0x${new k.default("0").toString(16)}`,gasLimit:void 0},l=yield lt(r,s);return l&&(r.gasLimit=l),yield ct(r,s)})))(i.token.address,o,i.contract,i.amt||pt,s,o),v=T.hash,g(v);else{if(i.opcode!==dt.TX)throw new Error(`Op ${i.opcode} not implemented!`);if(""===i.to)throw new Error("Submission: malformed to");if(0===i.data.length)throw new Error("Submission: malformed data");if(0===i.data.indexOf("0x")&&i.data.length<=2)throw new Error("Submission: malformed data");if(w={value:i.value,data:i.data,to:i.to,gasLimit:i.gasLimit,from:o,chainId:r},!w.gasLimit)try{const e=yield lt(w,s);e&&(w.gasLimit=e)}catch(e){console.debug(e)}if(T=yield ct(w,s),v=T.hash,g(v),!v)throw new Error(`Unexpected tx: ${v}`)}}catch(t){if(d(!1),y({spec:i,brief:a,subtitle:l}),console.error(t),t.message){m(mt({contractStatus:ee.Failed}));const n={error:t.message,brief:a};h&&Object.assign(n,h),e&&e(t,h),f(function(e,t){var n;const o=null===(n=z[e])||void 0===n?void 0:n.symbol,s=[{error:"insufficient",msg:E.i18n._("Insufficient funds - Please retry after depositing more {EtherTokenSymbol} into your wallet",{EtherTokenSymbol:o})},{error:["External Swap execution Failed","Return amount is not enough"],msg:E.i18n._("Price impact exceeds the slippage tolerance you set. Try increasing the slippage tolerance.")},{error:"SafeERC20: low-level call failed",msg:E.i18n._("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:E.i18n._("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:E.i18n._("RPC node data exception")},{error:['execution reverted:FORCESTOP ["originalError"'],msg:E.i18n._("ForceStop exception")},{error:["replacement transaction underpriced","Gasprice too low","transaction underprice"],msg:E.i18n._("Gas price is too low, please adjust in your wallet and try again")},{error:["MINT_INVALID"],msg:E.i18n._("No ForceStop access")},{error:["NOT_PHASE_EXE"],msg:E.i18n._("Unable to SETTLE during the cooling-off period")},{error:["params specify an EIP-1559transaction but the currentnetwork does not support"],msg:E.i18n._("Wallet incompatibility")},{error:["ALREADY_SETTLED"],msg:E.i18n._("This CP has been settled by other addrs")},{error:["create RFQ order failed]:LESS_THAN_FEE_LIMIT"],msg:E.i18n._("Service update, please wait and try again")}];let a="";return s.some((e=>Array.isArray(e.error)?e.error.some((n=>t.indexOf(n)>-1&&(a=e.msg,!0))):t.indexOf(e.error)>-1&&(a=e.msg,!0))),a||t}(r,t.message))}return st.Failed}y({spec:i,brief:a,subtitle:l}),C(!1),d(!1);const A=Object.assign(Object.assign(Object.assign(Object.assign({brief:a},i),w),{tx:v,subtitle:l}),h);m(mt({contractStatus:ee.Pending})),t&&t(v,A),u&&u();const O={brief:a,spec:i,tx:v,subtitle:l};if(p((e=>e.set(v,[O,ot.Running]))),c)return st.Submitted;if(u&&u(),null==T?void 0:T.wait){const e=yield T.wait(1);if(C(!0),e.status===at.Success)return"TX"===A.opcode&&m(mt({contractStatus:ee.TxSuccess})),"APPROVAL"===A.opcode&&m(mt({contractStatus:ee.ApproveSuccess})),b&&b(v),n&&n(v,A),p((e=>e.set(v,[O,ot.Success]))),st.Success}return C(!0),p((e=>e.set(v,[O,ot.Failed]))),st.Failed}))),[o,r,d,s]),A=a.useMemo((()=>({execute:T,requests:u,setShowing:y,waitingSubmit:l})),[T,u,y]),O=a.useCallback((()=>{y(null),w&&(w(),j(void 0))}),[w]);return{showing:b,showingDone:v,transactionTx:x,errorMessage:h,setErrorMessage:f,closeShowing:O,ctxVal:A,requests:u}}function ft(){const{requests:e}=gt(),t=[];return null==e||e.forEach((function([e,n]){n===ot.Running&&t.push(e)})),{runningRequests:t,isInflight:t.length>0}}const xt=a.createContext({execute:()=>Promise.resolve(st.Canceled),requests:void 0,waitingSubmit:!1});function gt(){return a.useContext(xt)}var bt;function yt(){return yt=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},yt.apply(this,arguments)}var vt=function(e){return S.createElement("svg",yt({width:"33px",height:"33px",viewBox:"0 0 33 33",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),bt||(bt=S.createElement("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},S.createElement("g",{transform:"translate(-186.000000, -375.000000)",stroke:"currentColor",strokeWidth:4},S.createElement("g",{transform:"translate(18.000000, 291.000000)"},S.createElement("g",{transform:"translate(40.000000, 83.000000)"},S.createElement("path",{d:"M159,32 C159,15.9837423 146.016258,3 130,3"})))))))};function Et({showingDone:e,errorMessage:t}){return t?v.jsx(o.Box,{component:r.ErrorWarn,sx:{width:64,height:64,color:"error.main"}}):e?v.jsx(o.Box,{component:r.DoneBorder,sx:{width:64,height:64,color:"success.main"}}):v.jsx(o.Box,{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:v.jsx(o.Box,{component:vt,sx:{position:"absolute",top:"-6px",right:"-6px",color:"primary.main"}})})}function Ct({showingDone:e,showing:t}){return v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:[v.jsx(o.Box,{sx:{mt:60},children:e?E.i18n._("{0} confirmed",{0:null==t?void 0:t.brief}):E.i18n._("{0} pending",{0:null==t?void 0:t.brief})}),(null==t?void 0:t.subtitle)?v.jsx(o.Box,{sx:{mt:20,typography:"body2"},children:null==t?void 0:t.subtitle}):""]})}function wt({isStarted:t,isEnded:n,tx:s}){const[i,l]=a.useState(0),{chainId:d}=c.useWeb3React(),u=a.useMemo((()=>`https://${q[d||1]}/tx/${s}`),[s,d]),p=a.useMemo((()=>{const e=Math.floor(i/60),t=i%60;return e?`${e}m ${t}s`:`${t}s`}),[i]),m=a.useRef();return a.useEffect((()=>(l(0),m.current=setInterval((()=>{l((e=>e+1))}),1e3),()=>{clearInterval(m.current)})),[t]),a.useEffect((()=>{clearInterval(m.current)}),[n]),v.jsxs(o.Box,{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:[v.jsxs(o.Box,{children:[v.jsx(e.Trans,{id:"Transaction Time:"}),p]}),v.jsxs(o.HoverOpacity,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},component:"a",href:u,target:"_blank",rel:"noopener noreferrer",children:[v.jsx(e.Trans,{id:"Tx"}),v.jsx(o.Box,{component:r.ArrowTopRightBorder,sx:{width:16,height:16,ml:6}})]})]})}function jt(t){var{children:n}=t,s=K(t,["children"]);const{ctxVal:a,showing:r,closeShowing:l,showingDone:c,errorMessage:d,transactionTx:u}=ht(s),p=i.useDispatch();return v.jsxs(xt.Provider,{value:a,children:[n,v.jsx(Ge,{open:!!r,onClose:l,children:v.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",px:20,pb:20,flex:1,overflowY:"auto"},children:[v.jsxs(o.Box,{children:[v.jsx(o.Box,{sx:{textAlign:"center",pt:60},children:v.jsx(Et,{showingDone:c,errorMessage:d})}),d?v.jsxs(o.Box,{sx:{textAlign:"center",mt:60},children:[v.jsx(o.Box,{children:v.jsx(e.Trans,{id:"Something went wrong."})}),v.jsx(o.Box,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:d})]}):v.jsxs(v.Fragment,{children:[v.jsx(Ct,{showingDone:c,showing:r}),v.jsx(wt,{isStarted:!!r,isEnded:c,tx:u})]})]}),v.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,onClick:()=>{p(mt({contractStatus:ee.Initial})),l()},sx:{mt:20},children:d?v.jsx(e.Trans,{id:"Dismiss"}):v.jsx(e.Trans,{id:"Close"})})]})})]})}function Tt({token:e,fiatPrice:n}){return{marginAmount:a.useMemo((()=>{var o;const s=null!==(o=null==e?void 0:e.decimals)&&void 0!==o?o:6,a=((e,n,o)=>{const s=new t.BigNumber(e).times(new t.BigNumber(10).pow(n));return o?s:s.dp(0)})(null!=n?new k.default(500).div(n):new k.default(0),s);return(a.lt(new k.default(1).times(new k.default(10).pow(s-3)))?new k.default(0):a).toString(10)}),[null==e?void 0:e.decimals,n])}}function At({width:e,height:t,feeRate:n,rebateTo:o,colorMode:s,apikey:r,defaultChainId:l,defaultToToken:c,defaultFromToken:d}){const u=i.useDispatch();a.useEffect((()=>{s&&u((e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_COLOR_MODE",payload:e})})))(s))}),[s]),a.useEffect((()=>{var e;l&&u((e=l,t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_CHAIN_ID",payload:e})}))))}),[l]),a.useEffect((()=>{u(mt({height:t}))}),[t]),a.useEffect((()=>{u(mt({width:e}))}),[e]),a.useEffect((()=>{r&&u(mt({apikey:r}))}),[r]),a.useEffect((()=>{n&&u(mt({feeRate:n}))}),[n]),a.useEffect((()=>{o&&u(mt({rebateTo:o}))}),[o]),a.useEffect((()=>{d&&u((e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_DEFAULT_FROM_TOKEN",payload:e})})))(d))}),[d]),a.useEffect((()=>{c&&u((e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_DEFAULT_TO_TOKEN",payload:e})})))(c))}),[c])}function Ot({refetch:e,interval:t}){let n;a.useEffect((()=>(e(),clearTimeout(n),n=setInterval((()=>{e()}),null!=t?t:15e3),()=>clearTimeout(n))),[e])}function Bt({fromToken:e,toToken:t,chainId:n}){const[o,s]=a.useState(!1),[i,r]=a.useState(""),[l,c]=a.useState(""),d=a.useCallback((()=>{if(!n||!e||!t)return;s(!0);const o=[e,t];I.default.post("https://api.dodoex.io/price-api/api/v1/price/current/batch",{networks:o.map((()=>(e=>V[e]||V[W.MAINNET])(n))),addresses:o.map((e=>e.address)),symbols:o.map((e=>e.symbol)),isCache:!0},{headers:{apikey:"dodofrontend777888ofopensource"}}).then((n=>{var o;s(!1);const a=null===(o=n.data)||void 0===o?void 0:o.data;a&&(r(a.find((t=>t.address===e.address)).price),c(a.find((e=>e.address===t.address)).price))})).catch((e=>{s(!1),console.error(e)}))}),[n,e,t]);return Ot({refetch:d}),{loading:o,refetch:d,toFiatPrice:l,fromFiatPrice:i}}const kt=e=>(null!=e?e:ie.getState()).settings.slippage,St=e=>(null!=e?e:ie.getState()).settings.ddl;var Rt;function It({toToken:e,fromToken:t,fromAmount:n,toAmount:o,marginAmount:s}){const{account:r,chainId:l,provider:d}=c.useWeb3React(),u=i.useSelector(re),p=a.useMemo((()=>l||u),[l,u]),m=i.useSelector(kt)||3,h=i.useSelector(St)||20,{feeRate:f,rebateTo:x,apikey:g,isReverseRouting:b}=i.useSelector(Ye),y=a.useMemo((()=>Math.floor(Date.now()/1e3)+60*h),[h]),[v,C]=a.useState(Rt.Initial),[w,j]=a.useState(null),[A,O]=a.useState(""),[B,k]=a.useState(null),[S,R]=a.useState(null),[D,L]=a.useState(null),[N,M]=a.useState(T.BigNumber.from(0)),[_,P]=a.useState(null),[F,U]=a.useState(null),[W,H]=a.useState(""),[$,z]=a.useState(""),[V,q]=a.useState(""),[K,Y]=a.useState(0),X=a.useCallback((()=>G(this,void 0,void 0,(function*(){if(!p||!t||!e)return;if(!b&&!n)return;if(b&&!o)return;C(Rt.Loading);const s={chainId:p,deadLine:y,apikey:g,slippage:m,source:"dodoV2AndMixWasm",toTokenAddress:e.address,toTokenDecimals:e.decimals,fromTokenAddress:t.address,fromTokenDecimals:t.decimals,userAddr:r||"0x0000000000000000000000000000000000000000"};b?s.toAmount=T.parseFixed(String(o||1),e.decimals).toString():s.fromAmount=T.parseFixed(String(n||1),t.decimals).toString(),x&&f&&(s.rebateTo=x,s.fee=f);try{const e=(yield I.default.get("https://api.dodoex.io/route-service/v2/widget/getdodoroute",{params:s})).data.data;if((null==e?void 0:e.resAmount)?(C(Rt.Success),j(e.resAmount),L(e.priceImpact),P(e.resPricePerFromToken),U(e.resPricePerToToken),k(e.baseFeeAmount),R(e.additionalFeeAmount),H(e.to),z(e.data),O(e.value),q(e.useSource),Y(e.duration)):C(Rt.Failed),!r||!d)return;const t=yield lt({from:r,to:e.to,value:e.value,data:e.data},d);t&&M(t)}catch(e){C(Rt.Failed),console.error(e)}}))),[y,r,p,e,f,m,x,t,d,n,o,g,b]);Ot({refetch:X});const Z=a.useMemo((()=>{const e=b?o:n;return v!==Rt.Loading&&e?w:null}),[v,b,o,n,w]),Q=function(){const{chainId:e,account:t}=c.useWeb3React(),n=gt();return a.useCallback((({to:e,data:o,useSource:s,duration:a,ddl:i,gasLimit:r,subtitle:l,value:c})=>{const d=60*i,u=c;s&&"weth"!==s.toLowerCase()&&r&&r.lt(3e4)&&console.debug("Warning: GasLimit less than the minimum!");const p={from:t,to:e,data:o,value:u,route:s,duration:a,ddlSecRel:d,gasLimit:r};n.execute(E.i18n._("Swap"),Object.assign({opcode:dt.TX},p),l)}),[t,e])}(),J=a.useCallback((e=>{t&&(b?w:n)&&Q({to:W,data:$,useSource:V,duration:K,ddl:h,value:A,subtitle:e})}),[W,h,$,K,V,t,n,N,w,A,b]);return{status:v,refetch:X,priceImpact:D,executeSwap:J,baseFeeAmount:B,resAmount:Z,additionalFeeAmount:S,resPricePerToToken:F,resPricePerFromToken:_}}!function(e){e.Initial="Initial",e.Loading="Loading",e.Failed="Failed",e.Success="Success"}(Rt||(Rt={}));function Dt(e){De(e),be(),ye();const{provider:t,connector:n}=c.useWeb3React();a.useEffect((()=>{const t=e.defaultChainId||1;(null==n?void 0:n.connectEagerly)?n.connectEagerly(t):n.activate(t)}),[n]),a.useEffect((()=>{const e=null==t?void 0:t.provider;e&&e.once&&e.once("chainChanged",(()=>{setTimeout((()=>{window.location.reload()}),200||100)}))}),[t]);const s=e.width||375,i=e.height||494;return At(Object.assign(Object.assign({},e),{width:s,height:i})),v.jsx(o.Box,{sx:{width:s,height:i,overflow:"hidden",position:"relative",display:"flex",flexDirection:"column",minWidth:335,minHeight:494,borderRadius:16,backgroundColor:"background.paper"},className:"dodo-widget-container",children:v.jsx(jt,{...e,children:e.children})})}function Lt(e){const t=o.createTheme({mode:e.colorMode,theme:e.theme,lang:e.locale||"en-US"}),n=a.useMemo((()=>e.defaultChainId||1),[e.defaultChainId]),s=Re({provider:e.provider,jsonRpcUrlMap:e.jsonRpcUrlMap,defaultChainId:n}),r=`${s.length}+${e.jsonRpcUrlMap?Object.entries(e.jsonRpcUrlMap):""}+${e.defaultChainId}+${n}`;return v.jsx(i.Provider,{store:ie,children:v.jsx(nt,{locale:e.locale,children:v.jsx(o.ThemeProvider,{theme:t,children:v.jsxs(c.Web3ReactProvider,{connectors:s,children:[v.jsx(o.CssBaseline,{container:".dodo-widget-container"}),v.jsx(Dt,{...e})]},r)})})})}function Nt(e){const{width:t}=i.useSelector(Ye),n=a.useMemo((()=>{let e="";return"number"==typeof t?e=`${t}px`:t&&(e=t),e?`calc(${e} - 40px)`:"auto"}),[t]);return v.jsx(o.QuestionTooltip,{container:document.querySelector(".dodo-widget-container"),maxWidth:n,...e})}function Mt({onClick:e}){const t=o.useTheme();return v.jsx(o.HoverOpacity,{sx:{width:"100%",position:"relative"},onClick:e,children:v.jsx(o.Box,{component:o.BaseButton,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:v.jsx(o.Box,{component:r.ArrowBack,sx:{width:18,color:"text.secondary"}})})})}function _t({open:t,execute:n,onClose:s,toToken:l,fromToken:c,fromAmount:d,toAmount:u,priceImpact:p,clearFromAmt:m,clearToAmt:h,baseFeeAmount:f,curToFiatPrice:x,curFromFiatPrice:g,pricePerFromToken:b,additionalFeeAmount:y}){var E,C;const w=o.useTheme(),j=i.useSelector(kt),T=i.useDispatch(),{contractStatus:A}=i.useSelector(Ye),O=a.useMemo((()=>new k.default(p).gt(15)),[p]),[B,S]=a.useState(!1),[R,I]=a.useState(!1);return a.useEffect((()=>{A!==ee.Pending&&s(),A===ee.TxSuccess&&(h(),m())}),[A]),a.useEffect((()=>{S(!1)}),[x]),v.jsx(Ge,{open:t,onClose:()=>{T(mt({contractStatus:ee.Initial})),s()},title:v.jsx(e.Trans,{id:"Swap summary"}),children:v.jsxs(o.Box,{sx:{margin:20,display:"flex",height:"100%",flexDirection:"column",borderTop:`1px solid ${w.palette.border.main}`},children:[v.jsxs(o.Box,{sx:{py:20,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexDirection:"column",borderBottom:`1px solid ${w.palette.border.main}`},children:[v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[v.jsxs(o.Box,{children:[v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[v.jsx(ze,{width:16,height:16,url:null==c?void 0:c.logoURI,address:null!==(E=null==c?void 0:c.address)&&void 0!==E?E:"",marginRight:6}),v.jsx(o.Box,{children:`${L({input:d,decimals:null==c?void 0:c.decimals})} ${null==c?void 0:c.symbol}`})]}),v.jsx(o.Box,{sx:{mt:4,typography:"h6",color:w.palette.text.secondary},children:g?`$${D({input:g,showDecimals:1})}`:"-"})]}),v.jsx(o.Box,{sx:{width:16,mx:16},component:r.DoubleRight}),v.jsxs(o.Box,{children:[v.jsxs(o.Box,{sx:{display:"flex"},children:[v.jsx(ze,{width:16,height:16,marginRight:6,url:null==l?void 0:l.logoURI,address:null!==(C=null==l?void 0:l.address)&&void 0!==C?C:""}),v.jsx(o.Box,{children:`${L({input:u,decimals:null==l?void 0:l.decimals})} ${null==l?void 0:l.symbol}`})]}),v.jsx(o.Box,{sx:{typography:"h6",mt:4,color:w.palette.text.secondary},children:x?`$${D({input:x,showDecimals:1})}(${p}%)`:"-"})]})]}),v.jsx(o.Box,{sx:{mt:12,typography:"h6"},children:`1 ${null==c?void 0:c.symbol} = ${L({input:new k.default(u).dividedBy(new k.default(d)),decimals:null==l?void 0:l.decimals})} ${null==l?void 0:l.symbol}`})]}),v.jsxs(o.Box,{sx:{py:15,typography:"body2",borderBottom:`1px solid ${w.palette.border.main}`},children:[v.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",color:w.palette.text.secondary},children:[v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[v.jsx(o.Box,{sx:{width:16,mr:7},component:r.DetailBorder}),v.jsx(e.Trans,{id:"Swap Detail"})]}),v.jsx(o.Box,{component:o.BaseButton,children:v.jsx(o.Box,{onClick:()=>I(!R),sx:{width:10,color:"text.secondary",transform:R?"rotateX(0deg)":"rotateX(180deg)"},component:r.CaretUp})})]}),v.jsxs(o.Box,{sx:{mt:16,display:R?"initial":"none"},children:[v.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[v.jsx(e.Trans,{id:"Basic Fee"}),v.jsx(Nt,{title:v.jsx(e.Trans,{id:"Estimated service provider fees"}),ml:5})]}),v.jsx(o.Box,{children:`${L({input:f,decimals:null==l?void 0:l.decimals})} ${null==l?void 0:l.symbol}`})]}),v.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[v.jsx(e.Trans,{id:"Additional Fee"}),v.jsx(Nt,{title:v.jsx(e.Trans,{id:"Additional routing fees set by the Widget user"}),ml:5})]}),v.jsx(o.Box,{children:`${L({input:y,decimals:null==l?void 0:l.decimals})} ${null==l?void 0:l.symbol}`})]}),v.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[v.jsx(e.Trans,{id:"Price Impact"}),v.jsx(Nt,{title:v.jsx(e.Trans,{id:"Due to the market condition, market price and estimated price may have a slight difference"}),ml:5})]}),v.jsx(o.Box,{children:`${p}%`})]}),v.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[v.jsx(e.Trans,{id:"Slippage"}),v.jsx(Nt,{title:v.jsx(e.Trans,{id:"High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:5})]}),v.jsx(o.Box,{children:j})]})]})]}),v.jsx(o.Box,{sx:{flex:1}}),O&&v.jsxs(o.Box,{sx:{mb:14,display:"flex",cursor:"pointer",justifyContent:"center",alignItems:"center",typography:"h6"},onClick:()=>S(!B),children:[v.jsx(o.Box,{sx:{mr:4,width:18,height:18,alignItems:"center"},children:B?v.jsx(o.Box,{sx:{width:"100%",height:"100%",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"secondary.main"},children:v.jsx(o.Box,{component:r.Done,sx:{width:14,color:"#1a1a1b"}})}):v.jsx(o.Box,{sx:{width:"100%",height:"100%",borderRadius:4,border:`1px solid ${w.palette.text.secondary}`}})}),v.jsx(o.Box,{children:v.jsx(e.Trans,{components:{0:v.jsx(o.Box,{component:"span",sx:{color:"error.main"}})},values:{priceImpact:p},id:"Price impact reaches <0>{priceImpact}</0>%, accept the quote"})})]}),v.jsx(o.Button,{isLoading:A==ee.Pending,disabled:O&&!B,fullWidth:!0,onClick:()=>{n(),T(mt({contractStatus:ee.Pending}))},children:A==ee.Pending?v.jsx(e.Trans,{id:"Confirming"}):v.jsx(e.Trans,{id:"Confirm swap"})})]})})}function Pt(e){var{sx:n,maxVal:s,decimals:a=2,onInputChange:i}=e,r=K(e,["sx","maxVal","decimals","onInputChange"]);return o.useTheme(),v.jsx(o.Input,{...r,onChange:e=>{const n=0===e.target.value.length?null:_(e.target.value,a),o=s&&n&&new t.BigNumber(n).gt(s)?s.toString():n;console.log("finalVal:",o),i&&i(o)}})}function Ft({open:t,onClose:n}){const s=o.useTheme(),r=i.useDispatch(),l=i.useSelector(kt),c=i.useSelector(St),d=a.useMemo((()=>Number(l)>=50),[l]);return v.jsx(Ge,{open:t,onClose:n,title:v.jsx(e.Trans,{id:"Settings"}),children:v.jsxs(o.Box,{sx:{mx:20},children:[v.jsxs(o.Box,{sx:{py:20,borderTop:`1px solid ${s.palette.border.main}`},children:[v.jsxs(o.Box,{sx:{mb:16,display:"flex",alignItems:"center"},children:[v.jsx(e.Trans,{id:"Slippage Tolerance"}),v.jsx(Nt,{title:v.jsx(e.Trans,{id:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:7})]}),v.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column"},children:[v.jsx(Pt,{fullWidth:!0,maxVal:100,value:l,placeholder:3..toString(),onInputChange:e=>{r((e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_SLIPPAGE",payload:e})})))(e))},suffix:v.jsx(o.Box,{sx:{color:"text.disabled"},children:"%"}),height:36}),d&&v.jsx(o.Box,{sx:{typography:"h6",mt:6,color:"error.main"},children:v.jsx(e.Trans,{id:"Maximum slippage do not exceed 50%"})})]})]}),v.jsxs(o.Box,{sx:{py:20,borderTop:`1px solid ${s.palette.border.main}`},children:[v.jsxs(o.Box,{sx:{mb:16,display:"flex",alignItems:"center"},children:[v.jsx(e.Trans,{id:"Transaction Deadline"}),v.jsx(Nt,{title:v.jsx(e.Trans,{id:"If your transaction time exceeds the deadline, your transaction will be rescinded."}),ml:7})]}),v.jsx(Pt,{value:c,fullWidth:!0,height:36,placeholder:E.i18n._("{DEFAULT_SWAP_DDL} minutes",{DEFAULT_SWAP_DDL:20}),onInputChange:e=>{r((e=>t=>G(void 0,void 0,void 0,(function*(){t({type:"SET_TRANSACTION_DDL",payload:e})})))(e?Math.max(Number(e),1):""))}})]})]})})}function Ut({toToken:t,fromToken:n,priceStatus:s,pricePerToToken:i,pricePerFromToken:l}){const[c,d]=a.useState("-"),[u,p]=a.useState(null),[m,h]=a.useState("-"),[f,x]=a.useState(null);a.useEffect((()=>{d(null==n?void 0:n.symbol),h(null==t?void 0:t.symbol),p(i),x(l)}),[n,t,i,l]);const g=a.useCallback((()=>{d(m),h(c),p(f),x(u)}),[c,u,m,f]);return v.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:{[Rt.Initial]:"-",[Rt.Loading]:v.jsxs(v.Fragment,{children:[v.jsx(o.RotatingIcon,{sx:{mr:5}}),v.jsx(e.Trans,{id:"Fetching best price..."})]}),[Rt.Failed]:v.jsxs(v.Fragment,{children:[v.jsx(o.Box,{component:r.Warn,sx:{width:15,mr:5,color:"warning.main"}}),v.jsx(e.Trans,{id:"Quote not available"})]}),[Rt.Success]:v.jsxs(v.Fragment,{children:[v.jsx(o.Box,{sx:{typography:"body2"},children:`1 ${c} = ${D({input:f,showDecimals:4})} ${m}`}),v.jsx(o.Box,{component:o.BaseButton,sx:{width:18,height:18,ml:6,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},children:v.jsx(o.Box,{sx:{width:16,color:"text.secondary"},onClick:g,component:r.Switch})})]})}[s]})}function Wt({open:t,onClose:n}){const s=i.useSelector(re);return v.jsx(Ge,{title:v.jsx(e.Trans,{id:"Connect to your wallet"}),open:t,onClose:n,children:v.jsx(o.Box,{sx:{mx:20,pb:20,border:"1px solid transparent",borderTopColor:"border.main"},children:Object.values(ke).map((t=>v.jsxs(o.Box,{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 s=Se[e];if(!s)throw new Error(`Unknown wallet type: ${e}`);const[a]=s;null===(o=a.activate(t))||void 0===o||o.catch((e=>{4001!==e.code?n(e):a.connectEagerly?a.connectEagerly(t):a.activate(t)}))}(t.type,s,(e=>{console.error(e)}))},children:[v.jsx(o.Box,{component:t.icon,sx:{width:32,height:32}}),v.jsx(o.Box,{sx:{mt:8,typography:"caption"},children:t.name}),v.jsx(o.Box,{sx:{mt:4,typography:"body2",color:"text.secondary"},children:v.jsx(e.Trans,{id:"Connect to your {0} Wallet",values:{0:t.name}})})]},t.type)))})})}function Ht(){const{connector:t}=c.useWeb3React(),[n,s]=a.useState(!1);return v.jsxs(v.Fragment,{children:[v.jsx(o.Button,{size:o.Button.Size.big,fullWidth:!0,onClick:()=>{t.deactivate?t.deactivate():t.resetState(),s(!0)},"data-testid":"connect-wallet-btn",children:v.jsx(e.Trans,{id:"Connect to a wallet"})}),v.jsx(Wt,{open:n,onClose:()=>s(!1)})]})}var $t;!function(e){e.Loading="Loading",e.Insufficient="ApprovalInsufficient",e.Approving="Approving",e.Sufficient="Sufficient",e.Unchecked="Unchecked"}($t||($t={}));const zt=({account:e,chainId:t,offset:n,contractAddress:o})=>{var s;const r=i.useSelector(re),l=a.useMemo((()=>{var e;return pe[null!==(e=t)&&void 0!==e?e:r]}),[t]),{isETH:d}=a.useMemo((()=>U(t)),[t]),{DODO_APPROVE:u}=l||{},p=null!==(s=null!=o?o:u)&&void 0!==s?s:null,m=function(e){const{account:t}=c.useWeb3React(),n=i.useSelector(re),o=i.useSelector(Ne),s=a.useMemo((()=>z[n]),[n]),r=a.useCallback((n=>{var a;if(!t||!e)return null;if(n.symbol===s.symbol&&P(n.address,s.address))return new k.default(pt);const i=null===(a=null==o?void 0:o[n.address.toLowerCase()])||void 0===a?void 0:a.tokenAllowances;return null!=i?i:null}),[t,e,s.symbol,s.address,o]);return r}(p),h=Ue(),{runningRequests:f}=ft(),x=i.useSelector(Fe),g=a.useMemo((()=>{var e;return null===(e=z[null!=t?t:r])||void 0===e?void 0:e.address}),[t]),b=a.useCallback(((t,o,s)=>{if(!t)return $t.Loading;const a=!!(null==f?void 0:f.find((e=>e.spec.opcode===dt.Approval&&e.spec.token.address===(null==t?void 0:t.address)))),i=null!=s?s:t?h(t):null,r=t?m(t):null,l=new k.default(null!=o?o:0);if(!e)return $t.Unchecked;if(!i||l.minus(null!=n?n:0).gt(i))return $t.Unchecked;if(l.isZero())return $t.Unchecked;return t.address===g?$t.Sufficient:a?$t.Approving:r&&l.minus(null!=n?n:0).gt(r)?$t.Insufficient:$t.Sufficient}),[h,m,e,n,p,t,x,f,g]),y=a.useCallback((e=>{const t=e?m(e):null;return("USDT"===(null==e?void 0:e.symbol)||(null==e?void 0:e.address.toLowerCase())==="0x6426e6017968377529487E0ef0aA4E7759724e05".toLowerCase())&&null!==t&&t.gt(0)}),[m]),v=gt(),C=i.useDispatch(),w=a.useCallback(((t,n)=>G(void 0,void 0,void 0,(function*(){if(!p||!e||!t)return;const o=(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),s=n?new k.default(0):void 0,a=n?E.i18n._("Reset"):E.i18n._("Approve");var i;(yield v.execute(`${a} ${o}`,{opcode:dt.Approval,token:t,contract:p,amt:s}))===st.Success&&C((i=null!=s?s:pt,e=>G(void 0,void 0,void 0,(function*(){e({type:"SET_ACCOUNT_ALLOWANCES",payload:i})}))))}))),[p,e,t,v,C]),j=a.useCallback((e=>{const t=new k.default(0);if(!e)return t.toNumber();const n=h(e);if(!n)return t.toNumber();let o=n;const s=d?.1:.02;return g===(null==e?void 0:e.address)&&(o=n.gt(s)?n.minus(s):t),o.toNumber()}),[t,h,d]);return{getApprovalState:b,getPendingRest:y,getMaxBalance:j,submitApprove:w}};function Vt(){var t,s;const l=o.useTheme(),{isInflight:d}=ft(),{chainId:u,account:p}=c.useWeb3React(),m=i.useDispatch(),{isReverseRouting:h}=i.useSelector(Ye),f=i.useSelector(re),x=i.useSelector(Pe),g=i.useSelector(_e),{isETH:b}=a.useMemo((()=>U(u)),[u]),y=a.useMemo((()=>{var e;return null===(e=z[null!=u?u:f])||void 0===e?void 0:e.address}),[u]),[E,C]=a.useState(""),[w,j]=a.useState(""),[T,A]=a.useState(""),[O,B]=a.useState(""),S=a.useMemo((()=>n.debounce((e=>A(e)),1e3)),[]),R=a.useMemo((()=>n.debounce((e=>B(e)),1e3)),[]),[I,N]=a.useState(null),[M,_]=a.useState(null),[P,F]=a.useState(!1),[H,$]=a.useState(!1),{toFiatPrice:V,fromFiatPrice:q}=Bt({chainId:u,toToken:M,fromToken:I}),K=Ue(),G=a.useMemo((()=>I?K(I):null),[I,K]);a.useMemo((()=>M?K(M):null),[M,K]);const{getApprovalState:Y,submitApprove:X,getPendingRest:Z,getMaxBalance:Q}=zt({account:p,chainId:u}),J=a.useMemo((()=>Z(h?M:I)),[null==I?void 0:I.address,null==M?void 0:M.address,Z,h]),{marginAmount:ee}=Tt({token:h?M:I,fiatPrice:h?V:q}),{resAmount:te,priceImpact:ne,executeSwap:oe,baseFeeAmount:se,additionalFeeAmount:ae,resPricePerToToken:ie,resPricePerFromToken:le,status:ce}=It({toToken:M,fromToken:I,marginAmount:ee,fromAmount:T,toAmount:O}),de=a.useCallback((e=>{const t=e.toString();C(t),S(t)}),[C,S]),ue=a.useCallback((e=>{const t=e.toString();j(t),R(t)}),[j,R]);a.useEffect((()=>{u&&(_(null),N(null),h?ue(""):de("")),g&&g.chainId===u&&(N(g),g.amount&&(m(mt({isReverseRouting:!1})),de(g.amount))),x&&x.chainId===u&&(_(x),x.amount&&g&&!g.amount&&(m(mt({isReverseRouting:!0})),ue(x.amount)))}),[x,g,u,de,ue]);const pe=a.useCallback((()=>{de(""),ue(""),N(M),_(I)}),[N,M,_,I,de,ue]),me=a.useCallback((e=>h?ue(Q(M)):de(Q(I))),[de,ue,Q,I,M,h]),he=a.useMemo((()=>(100*Number(ne)).toFixed(2)),[ne]),fe=a.useMemo((()=>{const e=h?te:T;return e&&q?new k.default(q).multipliedBy(e):null}),[q,T,h,te]),xe=a.useMemo((()=>{const e=h?O:te;return e&&V?new k.default(V).multipliedBy(e):null}),[V,O,h,te]),ge=a.useMemo((()=>v.jsxs(o.Box,{sx:{display:"flex",fontWeight:600,typography:"body2",alignItems:"center",justifyContent:"center"},children:[v.jsx(Nt,{title:v.jsx(e.Trans,{id:"Due to the market condition, market price and estimated price may have a slight difference"}),mr:8}),v.jsxs(o.Box,{sx:{display:"flex"},children:[v.jsx(e.Trans,{id:"Current price impact"}),v.jsxs(o.Box,{sx:{color:l.palette.error.main,ml:4},children:[he,"%"]})]})]})),[he]),be=a.useMemo((()=>v.jsx(Ut,{toToken:M,fromToken:I,priceStatus:ce,pricePerToToken:ie,pricePerFromToken:le})),[M,I,ce,ie,le]),ye=a.useMemo((()=>!W[u||1]),[u]),ve=a.useMemo((()=>ce===Rt.Loading?v.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:v.jsxs(v.Fragment,{children:[v.jsx(o.RotatingIcon,{sx:{mr:5}}),v.jsx(e.Trans,{id:"Fetching best price..."})]})}):ye?v.jsxs(v.Fragment,{children:[v.jsx(o.Box,{component:r.Warn,sx:{mr:6,width:16,color:"warning.main"}}),v.jsx(e.Trans,{id:"Unsupported network - switch to trade"})]}):E&&new k.default(he).gt(15)?ge:be),[ce,be,E,ge,he,ye]),Ee=a.useMemo((()=>h?new k.default(w).gt(0)?L({input:te,decimals:null==I?void 0:I.decimals}):"-":E),[E,w,te,I,h]),Ce=a.useMemo((()=>h?w:new k.default(E).gt(0)?L({input:te,decimals:null==M?void 0:M.decimals}):"-"),[E,w,te,M,h]),we=a.useMemo((()=>{const t=Y(I,h?te||0:T),n=t===$t.Approving,s=t===$t.Insufficient&&!J,a=b?.1:.02,i=y===(null==I?void 0:I.address),r=new k.default(G||0);return p?d?v.jsx(o.Button,{fullWidth:!0,isLoading:!0,disabled:!0,children:v.jsx(e.Trans,{id:"Transaction Pending"})}):I&&M?s?v.jsx(o.Button,{fullWidth:!0,disabled:n,onClick:()=>X(I),children:n?v.jsx(e.Trans,{id:"Approving"}):v.jsx(e.Trans,{id:"Approve"})}):new k.default(h?O:T).gt(0)?ce===Rt.Loading?v.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-fetch-price-btn",children:v.jsx(e.Trans,{id:"Fetching Price..."})}):te?r.lt(h?te:T)||i&&r.lte(a)?v.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-insufficient-balance-btn",children:v.jsx(e.Trans,{id:"Insufficient balance"})}):v.jsx(o.Button,{fullWidth:!0,onClick:()=>F(!0),"data-testid":"swap-review-btn",children:v.jsx(e.Trans,{id:"Review Swap"})}):v.jsx(o.Button,{fullWidth:!0,disabled:!0,children:v.jsx(e.Trans,{id:"Quote not available"})}):v.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-enter-amount-btn",children:v.jsx(e.Trans,{id:"Enter an amount"})}):v.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-select-token-btn",children:v.jsx(e.Trans,{id:"Select Tokens"})}):v.jsx(Ht,{})}),[b,p,O,T,M,te,I,d,oe,J,X,ce,G,Y,y,h]),je=a.useMemo((()=>I&&M?v.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[v.jsx(ze,{token:I,sx:{width:16,height:16,mr:6}}),`${L({input:h?te:T,decimals:null==I?void 0:I.decimals})} ${I.symbol}`,v.jsx(o.Box,{component:r.DoubleRight,sx:{width:12,height:12,mx:16}}),v.jsx(ze,{token:M,sx:{width:16,height:16,mr:6}}),`${L({input:h?O:te,decimals:null==M?void 0:M.decimals})} ${M.symbol}`]}):v.jsx(o.Box,{})),[I,M,T,O,te,h]);return v.jsxs(v.Fragment,{children:[v.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",typography:"caption",margin:20},children:[v.jsx(e.Trans,{id:"Swap"}),v.jsx(o.Box,{component:o.BaseButton,children:v.jsx(o.Box,{component:r.Setting,onClick:()=>$(!0),sx:{width:19,height:19,color:"text.primary",cursor:"pointer"}})})]}),v.jsxs(o.Box,{sx:{flex:1,padding:"0 20px 20px",overflowY:"auto"},children:[v.jsxs(o.Box,{children:[v.jsx(et,{sx:{mb:4},token:I,amt:Ee,onMaxClick:me,onInputChange:de,onInputFocus:()=>{h&&de(""),m(mt({isReverseRouting:!1}))},showMaxBtn:!h&&!E,occupiedAddrs:[null!==(t=null==M?void 0:M.address)&&void 0!==t?t:""],fiatPriceTxt:fe?`$${D({input:fe,showDecimals:1})}`:"-",onTokenChange:(e,t)=>{if(t)return pe();de(""),ue(""),N(e)},readOnly:h}),v.jsx(Mt,{onClick:pe}),v.jsx(et,{token:M,amt:Ce,onInputChange:ue,onInputFocus:()=>{h||ue(""),m(mt({isReverseRouting:!0}))},occupiedAddrs:[null!==(s=null==I?void 0:I.address)&&void 0!==s?s:""],fiatPriceTxt:xe?`$${D({input:xe,showDecimals:1})}(${he}%)`:"-",onTokenChange:(e,t)=>{if(t)return pe();de(""),ue(""),_(e)},readOnly:!h}),v.jsx(o.Box,{sx:{py:12,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexWrap:"wrap"},children:ve})]}),we,v.jsxs(o.Box,{sx:{mt:13,display:"flex",typography:"h6",cursor:"pointer",justifyContent:"center",alignItems:"center",color:l.palette.text.disabled},onClick:()=>window.open("https://app.dodoex.io"),children:[v.jsx(o.Box,{sx:{width:24,typography:"body2",transform:"translate(1px, 2px)","& path":{fill:l.palette.text.disabled}},component:r.Dodo}),v.jsx(e.Trans,{id:"Powered by DODO protocol"})]})]}),v.jsx(_t,{toToken:M,fromToken:I,fromAmount:h?te:T,toAmount:h?O:te,open:P,baseFeeAmount:se,priceImpact:he,additionalFeeAmount:ae,curToFiatPrice:xe,execute:()=>oe(je),clearFromAmt:()=>de(""),clearToAmt:()=>ue(""),curFromFiatPrice:fe,pricePerFromToken:le,onClose:()=>F(!1)}),v.jsx(Ft,{open:H,onClose:()=>$(!1)})]})}exports.InitSwapWidget=function(e){const t=document.getElementById("dodo-swap-widget");A.createRoot(t).render(v.jsx(Lt,{...e,children:v.jsx(Vt,{})}))},exports.SwapWidget=function(e){return v.jsx(Lt,{...e,children:v.jsx(Vt,{})})};
|
|
@@ -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>;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { AnyAction } from 'redux';
|
|
2
2
|
import { SwapWidgetProps } from '../..';
|
|
3
|
-
export declare
|
|
3
|
+
export declare enum ContractStatus {
|
|
4
|
+
Initial = "Initial",
|
|
5
|
+
Pending = "Pending",
|
|
6
|
+
ApproveSuccess = "ApproveSuccess",
|
|
7
|
+
TxSuccess = "TxSuccess",
|
|
8
|
+
Failed = "Failed"
|
|
9
|
+
}
|
|
10
|
+
export interface State extends SwapWidgetProps {
|
|
11
|
+
isReverseRouting?: boolean;
|
|
12
|
+
contractStatus?: ContractStatus;
|
|
13
|
+
}
|
|
4
14
|
export declare const initialState: State;
|
|
5
|
-
declare const _default: (state:
|
|
15
|
+
declare const _default: (state: State | undefined, action: AnyAction) => State;
|
|
6
16
|
export default _default;
|
|
@@ -12,6 +12,6 @@ declare const _default: () => import("redux").Reducer<import("redux").CombinedSt
|
|
|
12
12
|
settings: settingsState;
|
|
13
13
|
wallet: walletState;
|
|
14
14
|
token: tokenState;
|
|
15
|
-
globals:
|
|
15
|
+
globals: globalState;
|
|
16
16
|
}>, import("redux").AnyAction>;
|
|
17
17
|
export default _default;
|