diff --git a/package.json b/package.json
index 8ac6a94b36..bd982943b8 100644
--- a/package.json
+++ b/package.json
@@ -49,7 +49,7 @@
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@kybernetwork/oauth2": "1.0.0",
"@kyberswap/ks-sdk-classic": "^1.0.3",
- "@kyberswap/ks-sdk-core": "1.0.8",
+ "@kyberswap/ks-sdk-core": "1.0.9",
"@kyberswap/ks-sdk-elastic": "^1.1.2",
"@kyberswap/ks-sdk-solana": "^1.0.2",
"@lingui/loader": "~3.14.0",
@@ -199,7 +199,7 @@
"vite-tsconfig-paths": "^4.0.8"
},
"resolutions": {
- "@kyberswap/ks-sdk-core": "1.0.8",
+ "@kyberswap/ks-sdk-core": "1.0.9",
"react-error-overlay": "6.0.9",
"@lingui/babel-plugin-extract-messages": "3.14.0",
"@lingui/cli": "3.14.0",
diff --git a/src/assets/networks/avax-network.png b/src/assets/networks/avax-network.png
deleted file mode 100644
index 28b409a34a..0000000000
Binary files a/src/assets/networks/avax-network.png and /dev/null differ
diff --git a/src/assets/networks/bsc-network.png b/src/assets/networks/bsc-network.png
deleted file mode 100644
index 29e5f25782..0000000000
Binary files a/src/assets/networks/bsc-network.png and /dev/null differ
diff --git a/src/assets/networks/bttc.png b/src/assets/networks/bttc.png
deleted file mode 100644
index 26d324ef32..0000000000
Binary files a/src/assets/networks/bttc.png and /dev/null differ
diff --git a/src/assets/networks/ethw.png b/src/assets/networks/ethw.png
deleted file mode 100644
index 7292606b6c..0000000000
Binary files a/src/assets/networks/ethw.png and /dev/null differ
diff --git a/src/assets/networks/polygon-network.png b/src/assets/networks/polygon-network.png
deleted file mode 100644
index c3c157cdb5..0000000000
Binary files a/src/assets/networks/polygon-network.png and /dev/null differ
diff --git a/src/assets/networks/zksync-network.png b/src/assets/networks/zksync-network.png
deleted file mode 100644
index 95dcab2025..0000000000
Binary files a/src/assets/networks/zksync-network.png and /dev/null differ
diff --git a/src/assets/svg/eth_pow.svg b/src/assets/svg/eth_pow.svg
deleted file mode 100644
index b937dcdd76..0000000000
--- a/src/assets/svg/eth_pow.svg
+++ /dev/null
@@ -1,12 +0,0 @@
-
diff --git a/src/components/ClassicElasticTab.tsx b/src/components/ClassicElasticTab.tsx
index 7fdd07383c..7916413a4d 100644
--- a/src/components/ClassicElasticTab.tsx
+++ b/src/components/ClassicElasticTab.tsx
@@ -44,7 +44,7 @@ function ClassicElasticTab() {
const showLegacyExplicit = upToMedium ? false : isFarmpage ? shouldShowFarmTab : shouldShowPositionTab
- const dontShowLegacy = [ChainId.LINEA_TESTNET, ChainId.LINEA].includes(chainId)
+ const dontShowLegacy = [ChainId.ZKEVM, ChainId.LINEA].includes(chainId)
const legacyTag = (small?: boolean) => (
theme.red};
- margin-left: 2px;
- margin-top: -10px;
-`
-
const ListItem = styled.div<{ selected?: boolean }>`
width: 100%;
display: flex;
@@ -197,11 +189,6 @@ const Networks = ({
{name}
- {key === ChainId.LINEA && (
-
- New
-
- )}
{selected && !walletKey && }
{walletKey && (
diff --git a/src/components/SwapForm/AddMEVProtectionModal.tsx b/src/components/SwapForm/AddMEVProtectionModal.tsx
index dc6ff46402..cefff1d597 100644
--- a/src/components/SwapForm/AddMEVProtectionModal.tsx
+++ b/src/components/SwapForm/AddMEVProtectionModal.tsx
@@ -1,6 +1,5 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
import { Trans, t } from '@lingui/macro'
-import { Connector } from '@web3-react/types'
import { darken } from 'polished'
import { useCallback, useState } from 'react'
import { X } from 'react-feather'
@@ -14,12 +13,12 @@ import { NotificationType } from 'components/Announcement/type'
import { ButtonEmpty, ButtonOutlined, ButtonPrimary } from 'components/Button'
import Modal from 'components/Modal'
import Row, { RowBetween } from 'components/Row'
-import { didUserReject } from 'constants/connectors/utils'
import { Z_INDEXS } from 'constants/styles'
import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
import { useChangeNetwork } from 'hooks/web3/useChangeNetwork'
import { useNotify } from 'state/application/hooks'
import { ExternalLink, MEDIA_WIDTHS } from 'theme'
+import { friendlyError } from 'utils/errorMessage'
const Wrapper = styled.div`
padding: 20px;
@@ -113,10 +112,9 @@ export default function AddMEVProtectionModal({ isOpen, onClose }: { isOpen: boo
onClose?.()
mixpanelHandler(MIXPANEL_TYPE.MEV_ADD_RESULT, { type: addingOption.name, result: 'success' })
},
- (connector: Connector, error: Error) => {
- let reason = error?.message || 'Unknown reason'
- if (didUserReject(connector, error)) reason = 'User rejected'
- mixpanelHandler(MIXPANEL_TYPE.MEV_ADD_RESULT, { type: addingOption.name, result: 'fail', reason })
+ (error: Error) => {
+ const message = friendlyError(error)
+ mixpanelHandler(MIXPANEL_TYPE.MEV_ADD_RESULT, { type: addingOption.name, result: 'fail', reason: message })
},
)
}, [addNewNetwork, notify, onClose, selectedOption, mixpanelHandler])
diff --git a/src/components/SwapForm/PriceImpactNote.tsx b/src/components/SwapForm/PriceImpactNote.tsx
index 6de7af621c..5e5d4be797 100644
--- a/src/components/SwapForm/PriceImpactNote.tsx
+++ b/src/components/SwapForm/PriceImpactNote.tsx
@@ -5,8 +5,6 @@ import styled from 'styled-components'
import Row from 'components/Row'
import WarningNote from 'components/WarningNote'
-import { useActiveWeb3React } from 'hooks'
-import { checkAllowBypassPriceImpactRestriction } from 'utils/priceImpact'
import { checkPriceImpact } from 'utils/prices'
const TextUnderlineColor = styled(Text)`
@@ -33,11 +31,9 @@ type Props = {
}
const PriceImpactNote: FC = ({ isDegenMode, priceImpact }) => {
- const { chainId } = useActiveWeb3React()
const priceImpactResult = checkPriceImpact(priceImpact)
- const shouldHide = checkAllowBypassPriceImpactRestriction(chainId)
- if (typeof priceImpact !== 'number' || shouldHide) {
+ if (typeof priceImpact !== 'number') {
return null
}
diff --git a/src/components/SwapForm/SlippageSetting.tsx b/src/components/SwapForm/SlippageSetting.tsx
index d567b9c4a8..9aa9e4c8d1 100644
--- a/src/components/SwapForm/SlippageSetting.tsx
+++ b/src/components/SwapForm/SlippageSetting.tsx
@@ -1,12 +1,11 @@
import { Trans } from '@lingui/macro'
-import React, { ReactNode, useState } from 'react'
+import { ReactNode, useState } from 'react'
import { Flex, Text } from 'rebass'
import styled from 'styled-components'
import { ReactComponent as DropdownSVG } from 'assets/svg/down.svg'
import SlippageControl from 'components/SlippageControl'
import { MouseoverTooltip, TextDashed } from 'components/Tooltip'
-import { useActiveWeb3React } from 'hooks'
import useTheme from 'hooks/useTheme'
import { useSlippageSettingByPage } from 'state/user/hooks'
import { ExternalLink } from 'theme'
@@ -28,11 +27,10 @@ type Props = {
}
const SlippageSetting = ({ isStablePairSwap, rightComponent, tooltip, isCrossChain }: Props) => {
const theme = useTheme()
- const { chainId } = useActiveWeb3React()
const [expanded, setExpanded] = useState(false)
const { setRawSlippage, rawSlippage, isSlippageControlPinned } = useSlippageSettingByPage(isCrossChain)
- const defaultRawSlippage = getDefaultSlippage(chainId, isStablePairSwap)
+ const defaultRawSlippage = getDefaultSlippage(isStablePairSwap)
const isWarningSlippage = checkWarningSlippage(rawSlippage, isStablePairSwap)
if (!isSlippageControlPinned) {
diff --git a/src/components/SwapForm/SwapActionButton/SwapButtonWithPriceImpact.tsx b/src/components/SwapForm/SwapActionButton/SwapButtonWithPriceImpact.tsx
index edd1bba5ec..7184a009d4 100644
--- a/src/components/SwapForm/SwapActionButton/SwapButtonWithPriceImpact.tsx
+++ b/src/components/SwapForm/SwapActionButton/SwapButtonWithPriceImpact.tsx
@@ -6,7 +6,6 @@ import styled from 'styled-components'
import { ButtonPrimary } from 'components/Button'
import { MouseoverTooltip } from 'components/Tooltip'
import { Dots } from 'components/swapv2/styleds'
-import { useActiveWeb3React } from 'hooks'
import useTheme from 'hooks/useTheme'
import { useDegenModeManager } from 'state/user/hooks'
import { checkShouldDisableByPriceImpact } from 'utils/priceImpact'
@@ -50,7 +49,6 @@ export const SwapButtonWithPriceImpact = ({
showTooltipPriceImpact?: boolean
}) => {
const theme = useTheme()
- const { chainId } = useActiveWeb3React()
const [isDegenMode] = useDegenModeManager()
const priceImpactResult = checkPriceImpact(priceImpact)
@@ -74,7 +72,7 @@ export const SwapButtonWithPriceImpact = ({
)
}
- const shouldDisableByPriceImpact = checkShouldDisableByPriceImpact(chainId, isDegenMode, priceImpact)
+ const shouldDisableByPriceImpact = checkShouldDisableByPriceImpact(isDegenMode, priceImpact)
const shouldDisable = !route || !isApproved || shouldDisableByPriceImpact || disabled
if ((priceImpactResult.isVeryHigh || priceImpactResult.isInvalid) && isDegenMode) {
diff --git a/src/components/SwapForm/SwapModal/ConfirmSwapModalContent.tsx b/src/components/SwapForm/SwapModal/ConfirmSwapModalContent.tsx
index 200f7f2cd1..bbe2a361f1 100644
--- a/src/components/SwapForm/SwapModal/ConfirmSwapModalContent.tsx
+++ b/src/components/SwapForm/SwapModal/ConfirmSwapModalContent.tsx
@@ -1,7 +1,7 @@
import { Currency, CurrencyAmount, Price } from '@kyberswap/ks-sdk-core'
import { Trans } from '@lingui/macro'
import { transparentize } from 'polished'
-import React, { useMemo, useState } from 'react'
+import { useMemo, useState } from 'react'
import { Check, Info } from 'react-feather'
import { Flex, Text } from 'rebass'
import { calculatePriceImpact } from 'services/route/utils'
@@ -80,7 +80,7 @@ export default function ConfirmSwapModalContent({
onSwap,
}: Props) {
const theme = useTheme()
- const { isSolana, chainId } = useActiveWeb3React()
+ const { isSolana } = useActiveWeb3React()
const [encodeSolana] = useEncodeSolana()
const { routeSummary, slippage, isStablePairSwap, isAdvancedMode } = useSwapFormContext()
const [hasAcceptedNewAmount, setHasAcceptedNewAmount] = useState(false)
@@ -218,7 +218,7 @@ export default function ConfirmSwapModalContent({
const warningStyle =
priceImpactResult.isVeryHigh || priceImpactResult.isInvalid ? { background: theme.red } : undefined
- const shouldDisableByPriceImpact = checkShouldDisableByPriceImpact(chainId, isAdvancedMode, priceImpactFromBuild)
+ const shouldDisableByPriceImpact = checkShouldDisableByPriceImpact(isAdvancedMode, priceImpactFromBuild)
const isShowAcceptNewAmount =
outputChangePercent < SHOW_ACCEPT_NEW_AMOUNT_THRESHOLD || (isStablePairSwap && outputChangePercent < 0)
diff --git a/src/components/SwapForm/SwapModal/index.tsx b/src/components/SwapForm/SwapModal/index.tsx
index c8d9d2a569..f162f4a2bf 100644
--- a/src/components/SwapForm/SwapModal/index.tsx
+++ b/src/components/SwapForm/SwapModal/index.tsx
@@ -30,6 +30,7 @@ type Props = {
const SwapModal: React.FC = props => {
const { isOpen, tokenAddToMetaMask, onDismiss, swapCallback, buildResult, isBuildingRoute } = props
const { chainId, account } = useActiveWeb3React()
+
const dispatch = useDispatch()
// modal and loading
const [{ error, isAttemptingTx, txHash }, setSwapState] = useState<{
@@ -48,7 +49,7 @@ const SwapModal: React.FC = props => {
const amountOut = currencyOut && CurrencyAmount.fromRawAmount(currencyOut, buildResult?.data?.amountOut || '0')
// text to show while loading
- const pendingText = `Swapping ${routeSummary?.parsedAmountIn?.toSignificant(6)} ${
+ const pendingText = t`Swapping ${routeSummary?.parsedAmountIn?.toSignificant(6)} ${
currencyIn?.symbol
} for ${amountOut?.toSignificant(6)} ${currencyOut?.symbol}`
@@ -107,9 +108,8 @@ const SwapModal: React.FC = props => {
const hash = await swapCallback()
handleTxSubmitted(hash)
} catch (e) {
- if (e?.code !== 4001 && e?.code !== 'ACTION_REJECTED') captureSwapError(e)
- const msg = t`Something went wrong. Please try again`
- handleError(e.message === '[object Object]' ? msg : e.message || msg)
+ captureSwapError(e)
+ handleError(e.message)
}
}
diff --git a/src/components/SwapForm/index.tsx b/src/components/SwapForm/index.tsx
index 2f80770d06..d0d1b730c2 100644
--- a/src/components/SwapForm/index.tsx
+++ b/src/components/SwapForm/index.tsx
@@ -1,4 +1,4 @@
-import { ChainId, Currency, CurrencyAmount } from '@kyberswap/ks-sdk-core'
+import { Currency, CurrencyAmount } from '@kyberswap/ks-sdk-core'
import { Trans } from '@lingui/macro'
import { rgba } from 'polished'
import { stringify } from 'querystring'
@@ -216,26 +216,24 @@ const SwapForm: React.FC = props => {
- {chainId === ChainId.LINEA_TESTNET ? null : (
-
- navigate(
- `${APP_PATHS.PROFILE_MANAGE}${PROFILE_MANAGE_ROUTES.CREATE_ALERT}?${stringify({
- amount: typedValue || undefined,
- inputCurrency: currencyId(currencyIn, chainId),
- outputCurrency: currencyId(currencyOut, chainId),
- })}`,
- )
- }
- >
-
- {upToExtraSmall ? null : (
-
- Price Alert
-
- )}
-
- )}
+
+ navigate(
+ `${APP_PATHS.PROFILE_MANAGE}${PROFILE_MANAGE_ROUTES.CREATE_ALERT}?${stringify({
+ amount: typedValue || undefined,
+ inputCurrency: currencyId(currencyIn, chainId),
+ outputCurrency: currencyId(currencyOut, chainId),
+ })}`,
+ )
+ }
+ >
+
+ {upToExtraSmall ? null : (
+
+ Price Alert
+
+ )}
+
currencyIn && handleChangeCurrencyOut(currencyIn)} />
diff --git a/src/components/TransactionConfirmationModal/index.tsx b/src/components/TransactionConfirmationModal/index.tsx
index 26b1d9ec1a..cf6ccc8e87 100644
--- a/src/components/TransactionConfirmationModal/index.tsx
+++ b/src/components/TransactionConfirmationModal/index.tsx
@@ -22,7 +22,7 @@ import { VIEW_MODE } from 'state/user/reducer'
import { ExternalLink } from 'theme'
import { CloseIcon } from 'theme/components'
import { getEtherscanLink, getTokenLogoURL } from 'utils'
-import { errorFriendly } from 'utils/dmm'
+import { friendlyError } from 'utils/errorMessage'
const Wrapper = styled.div`
width: 100%;
@@ -280,9 +280,9 @@ export function TransactionErrorContent({
lineHeight={'24px'}
style={{ textAlign: 'center', width: '85%' }}
>
- {errorFriendly(message)}
+ {friendlyError(message)}
- {message !== errorFriendly(message) && (
+ {message !== friendlyError(message) && (
`
@@ -142,7 +142,7 @@ export default function SendToken({
setFlowState(state => ({
...state,
attemptingTxn: false,
- errorMessage: errorFriendly(error?.message ?? 'Error occur, please try again'),
+ errorMessage: friendlyError(error),
}))
}
}
diff --git a/src/components/swapv2/LimitOrder/helpers.ts b/src/components/swapv2/LimitOrder/helpers.ts
index 7bbefc2d0d..0f59adcb8c 100644
--- a/src/components/swapv2/LimitOrder/helpers.ts
+++ b/src/components/swapv2/LimitOrder/helpers.ts
@@ -132,6 +132,7 @@ export const calcPercentFilledOrder = (value: string, total: string, decimals: n
}
}
+// todo: move to friendlyError
export const getErrorMessage = (error: any) => {
console.error('Limit order error: ', error)
const errorCode: string = error?.response?.data?.code || error.code || ''
diff --git a/src/components/swapv2/styleds.tsx b/src/components/swapv2/styleds.tsx
index a09fa6b5ec..44b48ad8c8 100644
--- a/src/components/swapv2/styleds.tsx
+++ b/src/components/swapv2/styleds.tsx
@@ -8,7 +8,7 @@ import { AutoColumn } from 'components/Column'
import Modal, { ModalProps } from 'components/Modal'
import { Z_INDEXS } from 'constants/styles'
import useTheme from 'hooks/useTheme'
-import { errorFriendly } from 'utils/dmm'
+import { friendlyError } from 'utils/errorMessage'
export const PageWrapper = styled.div`
display: flex;
@@ -136,9 +136,9 @@ export function SwapCallbackError({ error, style = {} }: { error: string; style?
- {errorFriendly(error)}
+ {friendlyError(error)}
- {error !== errorFriendly(error) && (
+ {error !== friendlyError(error) && (
Boolean(window.ethereum)
@@ -51,21 +48,24 @@ export enum ErrorCode {
MM_ALREADY_PENDING = -32002,
ACTION_REJECTED = 'ACTION_REJECTED',
- WC_MODAL_CLOSED = 'Error: User closed modal',
- CB_REJECTED_REQUEST = 'Error: User denied account authorization',
- ALPHA_WALLET_USER_REJECTED_REQUEST = -32050,
+ WALLETCONNECT_MODAL_CLOSED = 'Error: User closed modal',
+ WALLETCONNECT_CANCELED = 'The transaction was cancelled',
+ COINBASE_REJECTED_REQUEST = 'Error: User denied account authorization',
+ ALPHA_WALLET_REJECTED_CODE = -32050,
ALPHA_WALLET_REJECTED = 'Request rejected',
- CANCELED = 'The transaction was cancelled',
}
-export function didUserReject(connector: Connector, error: any): boolean {
+const rejectedPhrases: string[] = ['user rejected transaction', 'user denied transaction', 'you must accept']
+
+export function didUserReject(error: any): boolean {
return (
error?.code === ErrorCode.USER_REJECTED_REQUEST ||
error?.code === ErrorCode.ACTION_REJECTED ||
- error?.code === ErrorCode.ALPHA_WALLET_USER_REJECTED_REQUEST ||
+ error?.code === ErrorCode.ALPHA_WALLET_REJECTED_CODE ||
error?.message === ErrorCode.ALPHA_WALLET_REJECTED ||
- (connector === walletConnectV2 && error?.toString?.() === ErrorCode.WC_MODAL_CLOSED) ||
- (connector === walletConnectV2 && error?.message === ErrorCode.CANCELED) ||
- (connector === coinbaseWallet && error?.toString?.() === ErrorCode.CB_REJECTED_REQUEST)
+ error?.message === ErrorCode.WALLETCONNECT_MODAL_CLOSED ||
+ error?.message === ErrorCode.WALLETCONNECT_CANCELED ||
+ error?.message === ErrorCode.WALLETCONNECT_MODAL_CLOSED ||
+ rejectedPhrases.some(phrase => error?.message?.toLowerCase?.()?.includes?.(phrase.toLowerCase()))
)
}
diff --git a/src/constants/index.ts b/src/constants/index.ts
index 4711fc4648..3b7218a4f2 100644
--- a/src/constants/index.ts
+++ b/src/constants/index.ts
@@ -197,7 +197,6 @@ export const DEFAULT_SLIPPAGES = [5, 10, 50, 100]
export const DEFAULT_SLIPPAGE = 50
export const DEFAULT_SLIPPAGE_STABLE_PAIR_SWAP = 5
-export const DEFAULT_SLIPPAGE_TESTNET = 1000
export const AGGREGATOR_WAITING_TIME = 1700 // 1700 means that we at least show '.' '..' '...' '.' '..' '...'
@@ -321,7 +320,7 @@ export const CHAINS_SUPPORT_CROSS_CHAIN =
]
: SUPPORTED_NETWORKS
-export const TYPE_AND_SWAP_NOT_SUPPORTED_CHAINS: ChainId[] = [ChainId.ZKSYNC, ChainId.LINEA_TESTNET, ChainId.LINEA]
+export const TYPE_AND_SWAP_NOT_SUPPORTED_CHAINS: ChainId[] = [ChainId.ZKSYNC, ChainId.LINEA, ChainId.ZKEVM]
export const SWAP_FEE_RECEIVER_ADDRESS = '0x4f82e73EDb06d29Ff62C91EC8f5Ff06571bdeb29'
diff --git a/src/constants/networks.ts b/src/constants/networks.ts
index 43ef0bd59f..3bf526dd5e 100644
--- a/src/constants/networks.ts
+++ b/src/constants/networks.ts
@@ -15,7 +15,6 @@ import {
fantom,
görli,
linea,
- lineaTestnet,
matic,
mumbai,
oasis,
@@ -26,6 +25,7 @@ import {
zksync,
} from './networks/index'
import { EVMNetworkInfo } from './networks/type'
+import zkEvm from './networks/zkevm'
type SOLANA_NETWORK = ChainId.SOLANA | ChainId.SOLANA_DEVNET
@@ -50,8 +50,8 @@ const NETWORKS_INFO_CONFIG: NETWORKS_INFO_CONFIG_TYPE = {
[ChainId.OASIS]: oasis,
[ChainId.OPTIMISM]: optimism,
[ChainId.ZKSYNC]: zksync,
- [ChainId.LINEA_TESTNET]: lineaTestnet,
[ChainId.LINEA]: linea,
+ [ChainId.ZKEVM]: zkEvm,
[ChainId.SOLANA]: solana,
[ChainId.SOLANA_DEVNET]: solanaDevnet,
} as const
@@ -71,20 +71,21 @@ export const SUPPORTED_NETWORKS = Object.keys(NETWORKS_INFO).map(Number).filter(
export const MAINNET_NETWORKS = [
ChainId.MAINNET,
- ChainId.BSCMAINNET,
- ChainId.MATIC,
- ChainId.AVAXMAINNET,
ChainId.ARBITRUM,
ChainId.OPTIMISM,
+ ChainId.LINEA,
+ ChainId.MATIC,
+ ChainId.ZKEVM,
+ ChainId.ZKSYNC,
+ ChainId.BSCMAINNET,
+ ChainId.AVAXMAINNET,
// ChainId.SOLANA,
- ChainId.BTTC,
- ChainId.OASIS,
ChainId.FANTOM,
+ ChainId.BTTC,
ChainId.CRONOS,
ChainId.VELAS,
+ ChainId.OASIS,
ChainId.AURORA,
- ChainId.ZKSYNC,
- ChainId.LINEA,
] as const
export const EVM_NETWORKS = SUPPORTED_NETWORKS.filter(chainId => getChainType(chainId) === ChainType.EVM) as Exclude<
@@ -165,8 +166,8 @@ export const STATIC_FEE_OPTIONS: { [chainId: number]: number[] | undefined } = {
[ChainId.OPTIMISM]: [8, 10, 50, 300, 500, 1000],
[ChainId.GÖRLI]: [8, 10, 50, 300, 500, 1000],
[ChainId.ZKSYNC]: [8, 10, 50, 300, 500, 1000],
- [ChainId.LINEA_TESTNET]: [8, 10, 50, 300, 500, 1000],
[ChainId.LINEA]: [8, 10, 50, 300, 500, 1000],
+ [ChainId.ZKEVM]: [8, 10, 50, 300, 500, 1000],
}
export const ONLY_STATIC_FEE_CHAINS = [
@@ -177,8 +178,8 @@ export const ONLY_STATIC_FEE_CHAINS = [
ChainId.OPTIMISM,
ChainId.GÖRLI,
ChainId.ZKSYNC,
- ChainId.LINEA_TESTNET,
ChainId.LINEA,
+ ChainId.ZKEVM,
]
// hardcode for unavailable subgraph
@@ -225,6 +226,3 @@ export const COMING_SOON_NETWORKS_FOR_MY_EARNINGS_CLASSIC: ChainId[] = [
ChainId.AURORA,
ChainId.OASIS,
]
-
-// by pass invalid price impact/unable to calculate price impact/price impact too large
-export const CHAINS_BYPASS_PRICE_IMPACT = [ChainId.LINEA_TESTNET]
diff --git a/src/constants/networks/avax-testnet.ts b/src/constants/networks/avax-testnet.ts
index 062b2cf556..e5e4fddc65 100644
--- a/src/constants/networks/avax-testnet.ts
+++ b/src/constants/networks/avax-testnet.ts
@@ -1,6 +1,5 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
-import AVAX from 'assets/networks/avax-network.png'
import { EVMNetworkInfo } from 'constants/networks/type'
const EMPTY = ''
@@ -15,7 +14,7 @@ const avaxTestnetInfo: EVMNetworkInfo = {
aggregatorRoute: 'avalanche',
poolFarmRoute: EMPTY,
name: 'Avalanche Testnet',
- icon: AVAX,
+ icon: 'https://storage.googleapis.com/ks-setting-a3aa20b7/31645e2e-9c40-4fdf-9ddf-50d24e5399e4.svg',
iconDark: NOT_SUPPORT,
iconSelected: NOT_SUPPORT,
iconDarkSelected: NOT_SUPPORT,
@@ -26,7 +25,7 @@ const avaxTestnetInfo: EVMNetworkInfo = {
nativeToken: {
symbol: 'AVAX',
name: 'AVAX',
- logo: AVAX,
+ logo: 'https://storage.googleapis.com/ks-setting-a3aa20b7/31645e2e-9c40-4fdf-9ddf-50d24e5399e4.svg',
decimal: 18,
minForGas: 10 ** 16,
},
diff --git a/src/constants/networks/avax.ts b/src/constants/networks/avax.ts
index b554852b2c..788137f7a6 100644
--- a/src/constants/networks/avax.ts
+++ b/src/constants/networks/avax.ts
@@ -1,6 +1,5 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
-import AVAX from 'assets/networks/avax-network.png'
import { EVMNetworkInfo } from 'constants/networks/type'
const EMPTY = ''
@@ -14,7 +13,7 @@ const avaxInfo: EVMNetworkInfo = {
poolFarmRoute: 'avalanche',
aggregatorRoute: 'avalanche',
name: 'Avalanche',
- icon: AVAX,
+ icon: 'https://storage.googleapis.com/ks-setting-a3aa20b7/31645e2e-9c40-4fdf-9ddf-50d24e5399e4.svg',
iconDark: NOT_SUPPORT,
iconSelected: NOT_SUPPORT,
iconDarkSelected: NOT_SUPPORT,
@@ -25,7 +24,7 @@ const avaxInfo: EVMNetworkInfo = {
nativeToken: {
symbol: 'AVAX',
name: 'AVAX',
- logo: AVAX,
+ logo: 'https://storage.googleapis.com/ks-setting-a3aa20b7/31645e2e-9c40-4fdf-9ddf-50d24e5399e4.svg',
decimal: 18,
minForGas: 10 ** 16,
},
diff --git a/src/constants/networks/bnb-testnet.ts b/src/constants/networks/bnb-testnet.ts
index 5e938470f9..cb87ef22f5 100644
--- a/src/constants/networks/bnb-testnet.ts
+++ b/src/constants/networks/bnb-testnet.ts
@@ -1,7 +1,6 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
import BnbLogo from 'assets/images/bnb-logo.png'
-import BSC from 'assets/networks/bsc-network.png'
import { EVMNetworkInfo } from 'constants/networks/type'
const EMPTY = ''
@@ -16,7 +15,7 @@ const bnbTestnetInfo: EVMNetworkInfo = {
poolFarmRoute: EMPTY,
aggregatorRoute: 'bsc',
name: 'BNB Testnet',
- icon: BSC,
+ icon: 'https://storage.googleapis.com/ks-setting-a3aa20b7/a44a3dbc-9150-4278-8354-7b5953f9a1ab.svg',
iconDark: NOT_SUPPORT,
iconSelected: NOT_SUPPORT,
iconDarkSelected: NOT_SUPPORT,
diff --git a/src/constants/networks/bnb.ts b/src/constants/networks/bnb.ts
index 098dce717f..bb5d96704e 100644
--- a/src/constants/networks/bnb.ts
+++ b/src/constants/networks/bnb.ts
@@ -1,7 +1,6 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
import BnbLogo from 'assets/images/bnb-logo.png'
-import BSC from 'assets/networks/bsc-network.png'
import { EVMNetworkInfo } from 'constants/networks/type'
const EMPTY = ''
@@ -15,7 +14,7 @@ const bnbInfo: EVMNetworkInfo = {
poolFarmRoute: 'bsc',
aggregatorRoute: 'bsc',
name: 'BNB Chain',
- icon: BSC,
+ icon: 'https://storage.googleapis.com/ks-setting-a3aa20b7/a44a3dbc-9150-4278-8354-7b5953f9a1ab.svg',
iconDark: NOT_SUPPORT,
iconSelected: NOT_SUPPORT,
iconDarkSelected: NOT_SUPPORT,
@@ -67,7 +66,7 @@ const bnbInfo: EVMNetworkInfo = {
routers: '0xF9c2b5746c946EF883ab2660BbbB1f10A5bdeAb4',
farms: ['0x7D5ba536ab244aAA1EA42aB88428847F25E3E676'],
farmv2Quoter: '0x6AFeb9EDd6Cf44fA8E89b1eee28284e6dD7705C8',
- farmV2S: ['0x3D6AfE2fB73fFEd2E3dD00c501A174554e147a43'],
+ farmV2S: ['0x3D6AfE2fB73fFEd2E3dD00c501A174554e147a43', '0xf2BcDf38baA52F6b0C1Db5B025DfFf01Ae1d6dBd'],
},
limitOrder: {
development: '0x26279604204aa9D3B530bcd8514fc4276bf0962C',
diff --git a/src/constants/networks/bttc.ts b/src/constants/networks/bttc.ts
index 952230b485..17153a778f 100644
--- a/src/constants/networks/bttc.ts
+++ b/src/constants/networks/bttc.ts
@@ -1,6 +1,5 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
-import BTT from 'assets/networks/bttc.png'
import { EVMNetworkInfo } from 'constants/networks/type'
const EMPTY = ''
@@ -15,7 +14,7 @@ const bttcInfo: EVMNetworkInfo = {
poolFarmRoute: 'bttc',
aggregatorRoute: 'bttc',
name: 'BitTorrent',
- icon: BTT,
+ icon: 'https://storage.googleapis.com/ks-setting-a3aa20b7/4877aa34-b675-4fb3-8de2-15ab8a8f6a53.svg',
iconDark: NOT_SUPPORT,
iconSelected: NOT_SUPPORT,
iconDarkSelected: NOT_SUPPORT,
@@ -26,7 +25,7 @@ const bttcInfo: EVMNetworkInfo = {
nativeToken: {
symbol: 'BTT',
name: 'BTT',
- logo: BTT,
+ logo: 'https://storage.googleapis.com/ks-setting-a3aa20b7/4877aa34-b675-4fb3-8de2-15ab8a8f6a53.svg',
decimal: 18,
minForGas: 10 ** 16,
},
diff --git a/src/constants/networks/ethereum.ts b/src/constants/networks/ethereum.ts
index e4ef482ddc..a6577db62c 100644
--- a/src/constants/networks/ethereum.ts
+++ b/src/constants/networks/ethereum.ts
@@ -65,7 +65,7 @@ const ethereumInfo: EVMNetworkInfo = {
initCodeHash: '0x00e263aaa3a2c06a89b53217a9e7aad7e15613490a72e0f95f303c4de2dc7045',
quoter: '0x4d47fd5a29904Dae0Ef51b1c450C9750F15D7856',
routers: '0xF9c2b5746c946EF883ab2660BbbB1f10A5bdeAb4',
- farms: [],
+ farms: ['0x7D5ba536ab244aAA1EA42aB88428847F25E3E676'],
farmv2Quoter: '0x6AFeb9EDd6Cf44fA8E89b1eee28284e6dD7705C8',
farmV2S: ['0x3D6AfE2fB73fFEd2E3dD00c501A174554e147a43'],
},
diff --git a/src/constants/networks/index.ts b/src/constants/networks/index.ts
index 352f7387a7..d1a7d0a58e 100644
--- a/src/constants/networks/index.ts
+++ b/src/constants/networks/index.ts
@@ -16,6 +16,5 @@ export { default as optimism } from './optimism'
export { default as solana } from './solana'
export { default as velas } from './velas'
export { default as zksync } from './zksync'
-export { default as lineaTestnet } from './linea-testnet'
export { default as linea } from './linea'
export { default as solanaDevnet } from './solana-devnet'
diff --git a/src/constants/networks/linea-testnet.ts b/src/constants/networks/linea-testnet.ts
deleted file mode 100644
index 6fb4aa49b7..0000000000
--- a/src/constants/networks/linea-testnet.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-import { ChainId } from '@kyberswap/ks-sdk-core'
-
-import EthereumLogo from 'assets/images/ethereum-logo.png'
-import { EVMNetworkInfo } from 'constants/networks/type'
-
-const EMPTY = ''
-const EMPTY_ARRAY: any[] = []
-const NOT_SUPPORT = null
-
-const lineaTestnetInfo: EVMNetworkInfo = {
- chainId: ChainId.LINEA_TESTNET,
- route: 'linea-goerli',
- ksSettingRoute: 'linea-goerli',
- priceRoute: 'linea-goerli',
- poolFarmRoute: 'linea-goerli',
- aggregatorRoute: 'linea-goerli',
- name: 'Linea Testnet',
- icon: 'https://linea.build/apple-touch-icon.png',
- iconDark: NOT_SUPPORT,
- iconSelected: NOT_SUPPORT,
- iconDarkSelected: NOT_SUPPORT,
- defaultBlockSubgraph: 'https://thegraph.goerli.zkevm.consensys.net/subgraphs/name/kybernetwork/linea-blocks',
- etherscanUrl: 'https://goerli.lineascan.build',
- etherscanName: 'Linea Explorer',
- bridgeURL: EMPTY,
- nativeToken: {
- symbol: 'ETH',
- name: 'LineaETH',
- logo: EthereumLogo,
- decimal: 18,
- minForGas: 10 ** 16,
- },
- defaultRpcUrl: 'https://rpc.goerli.linea.build',
- multicall: '0xcA11bde05977b3631167028862bE2a173976CA11',
- classic: {
- defaultSubgraph: 'https://thegraph.goerli.zkevm.consensys.net/subgraphs/name/kybernetwork/kyberswap-exchange-linea',
- static: {
- zap: '0x12731092dD6215872C5850b3782A07b6e3E15c9C',
- router: '0x179A3d2e958D185F47D1Db046b796C5242d68981',
- factory: '0x7d1EDa469a4b6BFe4DB07fABC75da65F2b90DE6E',
- },
- oldStatic: NOT_SUPPORT,
- dynamic: NOT_SUPPORT,
- claimReward: NOT_SUPPORT,
- fairlaunch: EMPTY_ARRAY,
- fairlaunchV2: EMPTY_ARRAY,
- },
- elastic: {
- defaultSubgraph: 'https://thegraph.goerli.zkevm.consensys.net/subgraphs/name/kybernetwork/kyberswap-elastic-linea',
- startBlock: 847294,
- coreFactory: '0x40b7Ae13F825DE3D422032E8EC66F81d42fAD2ac',
- nonfungiblePositionManager: '0x50C11d49a6c4e95e49A6D96FbCE8ee208921Bb47',
- tickReader: '0x32fa66849b9EDC8F144D8764EbF045eF0f508Bb8',
- initCodeHash: '0x00e263aaa3a2c06a89b53217a9e7aad7e15613490a72e0f95f303c4de2dc7045',
- quoter: '0xd47AbBEAE91043e4FC195b9416D4f0A24Bb52718',
- routers: '0x3565e6927239619fDFbd6405C4f0d9C2de58137B',
- farms: [],
- },
- limitOrder: {
- production: NOT_SUPPORT,
- development: NOT_SUPPORT,
- },
- averageBlockTimeInSeconds: 2, // TODO: check these info
- coingeckoNetworkId: NOT_SUPPORT,
- coingeckoNativeTokenId: NOT_SUPPORT,
- deBankSlug: EMPTY,
- dexToCompare: NOT_SUPPORT,
- geckoTermialId: NOT_SUPPORT,
-}
-
-export default lineaTestnetInfo
diff --git a/src/constants/networks/linea.ts b/src/constants/networks/linea.ts
index b5e956debc..4b1ff18f00 100644
--- a/src/constants/networks/linea.ts
+++ b/src/constants/networks/linea.ts
@@ -15,7 +15,7 @@ const lineaInfo: EVMNetworkInfo = {
poolFarmRoute: 'linea',
aggregatorRoute: 'linea',
name: 'Linea',
- icon: 'https://linea.build/apple-touch-icon.png',
+ icon: 'https://storage.googleapis.com/ks-setting-a3aa20b7/5c7ac975-e5af-4a02-8586-da6acfee9ec8.svg',
iconDark: NOT_SUPPORT,
iconSelected: NOT_SUPPORT,
iconDarkSelected: NOT_SUPPORT,
diff --git a/src/constants/networks/matic.ts b/src/constants/networks/matic.ts
index ff455a4447..7d05a9e163 100644
--- a/src/constants/networks/matic.ts
+++ b/src/constants/networks/matic.ts
@@ -1,6 +1,5 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
-import Polygon from 'assets/networks/polygon-network.png'
import { EVMNetworkInfo } from 'constants/networks/type'
const EMPTY = ''
@@ -13,8 +12,8 @@ const maticInfo: EVMNetworkInfo = {
priceRoute: 'polygon',
poolFarmRoute: 'polygon',
aggregatorRoute: 'polygon',
- name: 'Polygon',
- icon: Polygon,
+ name: 'Polygon PoS',
+ icon: 'https://storage.googleapis.com/ks-setting-a3aa20b7/78dfb4fb-089b-431d-8725-b5de2cea0bfc.svg',
iconDark: NOT_SUPPORT,
iconSelected: NOT_SUPPORT,
iconDarkSelected: NOT_SUPPORT,
@@ -25,7 +24,7 @@ const maticInfo: EVMNetworkInfo = {
nativeToken: {
symbol: 'MATIC',
name: 'Polygon',
- logo: Polygon,
+ logo: 'https://storage.googleapis.com/ks-setting-a3aa20b7/78dfb4fb-089b-431d-8725-b5de2cea0bfc.svg',
decimal: 18,
minForGas: 10 ** 17,
},
diff --git a/src/constants/networks/mumbai.ts b/src/constants/networks/mumbai.ts
index 4fb0d89f7b..5f6a045c48 100644
--- a/src/constants/networks/mumbai.ts
+++ b/src/constants/networks/mumbai.ts
@@ -1,6 +1,5 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
-import Polygon from 'assets/networks/polygon-network.png'
import { EVMNetworkInfo } from 'constants/networks/type'
const EMPTY = ''
@@ -15,7 +14,7 @@ const mumbaiInfo: EVMNetworkInfo = {
poolFarmRoute: EMPTY,
aggregatorRoute: 'mumbai',
name: 'Mumbai',
- icon: Polygon,
+ icon: 'https://storage.googleapis.com/ks-setting-a3aa20b7/78dfb4fb-089b-431d-8725-b5de2cea0bfc.svg',
iconDark: NOT_SUPPORT,
iconSelected: NOT_SUPPORT,
iconDarkSelected: NOT_SUPPORT,
@@ -26,7 +25,7 @@ const mumbaiInfo: EVMNetworkInfo = {
nativeToken: {
symbol: 'MATIC',
name: 'Polygon',
- logo: Polygon,
+ logo: 'https://storage.googleapis.com/ks-setting-a3aa20b7/78dfb4fb-089b-431d-8725-b5de2cea0bfc.svg',
decimal: 18,
minForGas: 10 ** 16,
},
diff --git a/src/constants/networks/zkevm.ts b/src/constants/networks/zkevm.ts
new file mode 100644
index 0000000000..413f621558
--- /dev/null
+++ b/src/constants/networks/zkevm.ts
@@ -0,0 +1,76 @@
+import { ChainId } from '@kyberswap/ks-sdk-core'
+
+import EthereumLogo from 'assets/images/ethereum-logo.png'
+import { EVMNetworkInfo } from 'constants/networks/type'
+
+const EMPTY = ''
+const EMPTY_ARRAY: any[] = []
+const NOT_SUPPORT = null
+
+const zkEvm: EVMNetworkInfo = {
+ chainId: ChainId.ZKEVM,
+ route: 'polygon-zkevm',
+ ksSettingRoute: 'polygon-zkevm',
+ priceRoute: 'polygon-zkevm',
+ poolFarmRoute: 'polygon-zkevm',
+ aggregatorRoute: 'polygon-zkevm',
+ name: 'Polygon zkEVM',
+ icon: 'https://storage.googleapis.com/ks-setting-a3aa20b7/013aecc7-9868-4b06-a056-7dd5997b4139.svg',
+ iconDark: NOT_SUPPORT,
+ iconSelected: NOT_SUPPORT,
+ iconDarkSelected: NOT_SUPPORT,
+ defaultBlockSubgraph:
+ 'https://polygon-zkevm-graph.kyberengineering.io/subgraphs/name/kybernetwork/polygon-zkevm-blocks',
+ etherscanUrl: 'https://zkevm.polygonscan.com',
+ etherscanName: 'Polygon zkEVM Explorer',
+ bridgeURL: EMPTY,
+ nativeToken: {
+ symbol: 'ETH',
+ name: 'ETH',
+ logo: EthereumLogo,
+ decimal: 18,
+ minForGas: 10 ** 16,
+ },
+ defaultRpcUrl: 'https://zkevm-rpc.com',
+ multicall: '0xcA11bde05977b3631167028862bE2a173976CA11',
+ classic: {
+ defaultSubgraph:
+ 'https://polygon-zkevm-graph.kyberengineering.io/subgraphs/name/kybernetwork/kyberswap-exchange-polygon-zkevm',
+ static: {
+ zap: '0x2abE8750e4a65584d7452316356128C936273e0D',
+ router: '0x5649B4DD00780e99Bab7Abb4A3d581Ea1aEB23D0',
+ factory: '0x1c758aF0688502e49140230F6b0EBd376d429be5',
+ },
+ oldStatic: NOT_SUPPORT,
+ dynamic: NOT_SUPPORT,
+ claimReward: NOT_SUPPORT,
+ fairlaunch: EMPTY_ARRAY,
+ fairlaunchV2: EMPTY_ARRAY,
+ },
+ elastic: {
+ defaultSubgraph:
+ 'https://polygon-zkevm-graph.kyberengineering.io/subgraphs/name/kybernetwork/kyberswap-elastic-polygon-zkevm',
+ startBlock: 4164470,
+ coreFactory: '0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A',
+ nonfungiblePositionManager: '0xe222fBE074A436145b255442D919E4E3A6c6a480',
+ tickReader: '0x8Fd8Cb948965d9305999D767A02bf79833EADbB3',
+ initCodeHash: '0x00e263aaa3a2c06a89b53217a9e7aad7e15613490a72e0f95f303c4de2dc7045',
+ quoter: '0x4d47fd5a29904Dae0Ef51b1c450C9750F15D7856',
+ routers: '0xF9c2b5746c946EF883ab2660BbbB1f10A5bdeAb4',
+ farms: ['0x7D5ba536ab244aAA1EA42aB88428847F25E3E676'],
+ farmv2Quoter: '0x6AFeb9EDd6Cf44fA8E89b1eee28284e6dD7705C8',
+ farmV2S: ['0x3D6AfE2fB73fFEd2E3dD00c501A174554e147a43', '0xf2BcDf38baA52F6b0C1Db5B025DfFf01Ae1d6dBd'],
+ },
+ limitOrder: {
+ production: NOT_SUPPORT,
+ development: NOT_SUPPORT,
+ },
+ averageBlockTimeInSeconds: 2, // TODO: check these info
+ coingeckoNetworkId: 'polygon-zkevm',
+ coingeckoNativeTokenId: 'ethereum',
+ deBankSlug: EMPTY,
+ dexToCompare: NOT_SUPPORT,
+ geckoTermialId: NOT_SUPPORT,
+}
+
+export default zkEvm
diff --git a/src/constants/networks/zksync.ts b/src/constants/networks/zksync.ts
index a567a5b412..2178bd64fe 100644
--- a/src/constants/networks/zksync.ts
+++ b/src/constants/networks/zksync.ts
@@ -1,7 +1,6 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
import EthereumLogo from 'assets/images/ethereum-logo.png'
-import zkSync from 'assets/networks/zksync-network.png'
import { EVMNetworkInfo } from 'constants/networks/type'
const EMPTY = ''
@@ -18,7 +17,7 @@ const zkSyncInfo: EVMNetworkInfo = {
poolFarmRoute: 'zksync',
aggregatorRoute: 'zksync',
name: 'zkSync Era',
- icon: zkSync,
+ icon: 'https://storage.googleapis.com/ks-setting-a3aa20b7/ad122023-76dd-4cdd-ad5a-7572726f004f.svg',
iconDark: NOT_SUPPORT,
iconSelected: NOT_SUPPORT,
iconDarkSelected: NOT_SUPPORT,
diff --git a/src/constants/tokens.ts b/src/constants/tokens.ts
index a133595a66..dc7030a6c1 100644
--- a/src/constants/tokens.ts
+++ b/src/constants/tokens.ts
@@ -64,7 +64,7 @@ export const STABLE_COIN_ADDRESSES_TO_TAKE_FEE: Record = {
[ChainId.FANTOM]: [],
[ChainId.BSCMAINNET]: [],
[ChainId.ARBITRUM]: [],
- [ChainId.LINEA_TESTNET]: [],
+ [ChainId.ZKEVM]: [],
[ChainId.LINEA]: [],
[ChainId.SOLANA_DEVNET]: [],
}
@@ -163,7 +163,12 @@ export const SUPER_STABLE_COINS_ADDRESS: { [chainId in ChainId]: string[] } = {
[ChainId.MUMBAI]: [],
[ChainId.BSCTESTNET]: [],
[ChainId.AVAXTESTNET]: [],
- [ChainId.LINEA_TESTNET]: [],
+ [ChainId.ZKEVM]: [
+ '0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035', // USDC
+ '0x1E4a5963aBFD975d8c9021ce480b42188849D41d', // USDT
+ '0xC5015b9d9161Dca7e18e32f6f25C4aD850731Fd4', // DAI
+ ],
+
[ChainId.LINEA]: [],
[ChainId.SOLANA_DEVNET]: [],
}
@@ -213,7 +218,7 @@ export const CORRELATED_COINS_ADDRESS: { [chainId in ChainId]: string[][] } = {
[ChainId.MUMBAI]: [],
[ChainId.BSCTESTNET]: [],
[ChainId.AVAXTESTNET]: [],
- [ChainId.LINEA_TESTNET]: [],
+ [ChainId.ZKEVM]: [],
[ChainId.LINEA]: [],
[ChainId.SOLANA_DEVNET]: [],
}
@@ -292,16 +297,8 @@ export const DAI: { [chainId in ChainId]: Token } = {
'DAI',
'Dai Stablecoin',
),
- [ChainId.LINEA_TESTNET]: new Token(
- ChainId.LINEA_TESTNET,
- '0x8741Ba6225A6BF91f9D73531A98A89807857a2B3',
- 18,
- 'DAI',
- 'Dai',
- ),
-
- //not existing
- [ChainId.LINEA]: new Token(ChainId.LINEA, '0x8741Ba6225A6BF91f9D73531A98A89807857a2B3', 18, 'DAI', 'Dai'),
+ [ChainId.ZKEVM]: new Token(ChainId.ZKEVM, '0xC5015b9d9161Dca7e18e32f6f25C4aD850731Fd4', 18, 'DAI', 'Dai'),
+ [ChainId.LINEA]: new Token(ChainId.LINEA, '0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5', 18, 'DAI', 'Dai'),
//not existing on Velas
[ChainId.VELAS]: new Token(ChainId.VELAS, '0xe7dC549AE8DB61BDE71F22097BEcc8dB542cA100', 18, 'DAI', 'Dai Stablecoin'),
@@ -387,16 +384,8 @@ export const USDC: { [chainId in ChainId]: Token } = {
'USDC',
'USD Coin',
),
- [ChainId.LINEA_TESTNET]: new Token(
- ChainId.LINEA_TESTNET,
- '0xf56dc6695cF1f5c364eDEbC7Dc7077ac9B586068',
- 6,
- 'USDC',
- 'USD Coin',
- ),
-
- // not existing
- [ChainId.LINEA]: new Token(ChainId.LINEA, '0xf56dc6695cF1f5c364eDEbC7Dc7077ac9B586068', 6, 'USDC', 'USD Coin'),
+ [ChainId.ZKEVM]: new Token(ChainId.ZKEVM, '0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035', 6, 'USDC', 'USD Coin'),
+ [ChainId.LINEA]: new Token(ChainId.LINEA, '0x176211869cA2b568f2A7D4EE941E073a821EE1ff', 6, 'USDC', 'USD Coin'),
}
export const USDT: { [chainId in ChainId]: Token } = {
@@ -452,17 +441,8 @@ export const USDT: { [chainId in ChainId]: Token } = {
'USDT',
'Tether USD',
),
-
- [ChainId.LINEA_TESTNET]: new Token(
- ChainId.LINEA_TESTNET,
- '0x1990BC6dfe2ef605Bfc08f5A23564dB75642Ad73',
- 6,
- 'USDT',
- 'Tether USD',
- ),
-
- // not existing
- [ChainId.LINEA]: new Token(ChainId.LINEA, '0x1990BC6dfe2ef605Bfc08f5A23564dB75642Ad73', 6, 'USDT', 'Tether USD'),
+ [ChainId.ZKEVM]: new Token(ChainId.ZKEVM, '0x1E4a5963aBFD975d8c9021ce480b42188849D41d', 6, 'USDT', 'Tether USD'),
+ [ChainId.LINEA]: new Token(ChainId.LINEA, '0xA219439258ca9da29E9Cc4cE5596924745e12B93', 6, 'USDT', 'Tether USD'),
[ChainId.ZKSYNC]: new Token(ChainId.ZKSYNC, '0x493257fd37edb34451f62edf8d2a0c418852ba4c', 6, 'USDT', 'Tether USD'),
[ChainId.SOLANA]: new Token(ChainId.SOLANA, 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', 6, 'USDT', 'Tether USD'),
@@ -557,6 +537,8 @@ export const KNC: { [chainId in ChainId]: Token } = {
'KNC',
'Kyber Network Crystal',
),
+ [ChainId.LINEA]: new Token(ChainId.LINEA, '0x3b2F62d42DB19B30588648bf1c184865D4C3B1D6', 18, 'KNC', 'KNC'),
+
// TODO(viet-nv): this address doesn't exist. check again
[ChainId.ZKSYNC]: new Token(
ChainId.ZKSYNC,
@@ -581,15 +563,7 @@ export const KNC: { [chainId in ChainId]: Token } = {
),
// not existing
- [ChainId.LINEA_TESTNET]: new Token(
- ChainId.LINEA_TESTNET,
- '0x6Cb9750a92643382e020eA9a170AbB83Df05F30B',
- 6,
- 'KNC',
- 'KNC',
- ),
- // not existing
- [ChainId.LINEA]: new Token(ChainId.LINEA, '0x6Cb9750a92643382e020eA9a170AbB83Df05F30B', 6, 'KNC', 'KNC'),
+ [ChainId.ZKEVM]: new Token(ChainId.ZKEVM, '0x3b2F62d42DB19B30588648bf1c184865D4C3B1D6', 18, 'KNC', 'KNC'),
}
export const PINNED_PAIRS: { readonly [chainId in ChainId]?: [Token, Token][] } = {
@@ -619,8 +593,8 @@ export const DEFAULT_OUTPUT_TOKEN_BY_CHAIN: Partial> = {
[ChainId.SOLANA]: USDC[ChainId.SOLANA],
[ChainId.GÖRLI]: KNC[ChainId.GÖRLI],
[ChainId.ZKSYNC]: USDC[ChainId.ZKSYNC],
- [ChainId.LINEA_TESTNET]: USDC[ChainId.LINEA_TESTNET],
- [ChainId.LINEA]: new Token(ChainId.LINEA, '0x7d43aabc515c356145049227cee54b608342c0ad', 18, 'BUSD', 'BUSD'),
+ [ChainId.ZKEVM]: USDT[ChainId.ZKEVM],
+ [ChainId.LINEA]: USDC[ChainId.LINEA],
}
export const DEFAULT_SWAP_FEE_STABLE_PAIRS = 4
diff --git a/src/hooks/kyberdao/index.tsx b/src/hooks/kyberdao/index.tsx
index be14342034..39732e3974 100644
--- a/src/hooks/kyberdao/index.tsx
+++ b/src/hooks/kyberdao/index.tsx
@@ -37,7 +37,7 @@ import { useTransactionAdder } from 'state/transactions/hooks'
import { TRANSACTION_TYPE } from 'state/transactions/type'
import { calculateGasMargin } from 'utils'
import { aggregateValue } from 'utils/array'
-import { formatWalletErrorMessage } from 'utils/errorMessage'
+import { friendlyError } from 'utils/errorMessage'
import { formatUnitsToFixed } from 'utils/formatBalance'
import { sendEVMTransaction } from 'utils/sendTransaction'
@@ -89,7 +89,7 @@ export function useKyberDaoStakeActions() {
})
return tx.hash
} catch (error) {
- if (error?.code === 4001 || error?.code === 'ACTION_REJECTED') {
+ if (didUserReject(error)) {
throw new Error('Transaction rejected.')
} else {
throw error
@@ -120,7 +120,7 @@ export function useKyberDaoStakeActions() {
})
return tx.hash
} catch (error) {
- if (error?.code === 4001 || error?.code === 'ACTION_REJECTED') {
+ if (didUserReject(error)) {
throw new Error('Transaction rejected.')
} else {
throw error
@@ -155,7 +155,7 @@ export function useKyberDaoStakeActions() {
})
return tx.hash
} catch (error) {
- if (error?.code === 4001 || error?.code === 'ACTION_REJECTED') {
+ if (didUserReject(error)) {
throw new Error('Transaction rejected.')
} else {
throw error
@@ -181,7 +181,7 @@ export function useKyberDaoStakeActions() {
})
return tx.hash
} catch (error) {
- if (error?.code === 4001 || error?.code === 'ACTION_REJECTED') {
+ if (didUserReject(error)) {
throw new Error('Transaction rejected.')
} else {
throw error
@@ -208,7 +208,7 @@ export function useKyberDaoStakeActions() {
})
return tx.hash
} catch (error) {
- if (error?.code === 4001 || error?.code === 'ACTION_REJECTED') {
+ if (didUserReject(error)) {
throw new Error('Transaction rejected.')
} else {
throw error
@@ -272,7 +272,7 @@ export function useClaimVotingRewards() {
})
return tx.hash as string
} catch (error) {
- if (error?.code === 4001 || error?.code === 'ACTION_REJECTED') {
+ if (didUserReject(error)) {
throw new Error('Transaction rejected.')
} else {
throw error
@@ -312,7 +312,7 @@ export const useVotingActions = () => {
})
return tx.hash
} catch (error) {
- if (error?.code === 4001 || error?.code === 'ACTION_REJECTED') {
+ if (didUserReject(error)) {
throw new Error('Transaction rejected.')
} else {
throw error
@@ -620,7 +620,7 @@ export function useGasRefundInfo({ rewardStatus = KNCUtilityTabs.Available }: {
export function useClaimGasRefundRewards() {
const { account, chainId } = useActiveWeb3React()
- const { library, connector } = useWeb3React()
+ const { library } = useWeb3React()
const addTransactionWithType = useTransactionAdder()
const { claimableReward } = useGasRefundInfo({})
const refetch = useRefetchGasRefundInfo()
@@ -669,25 +669,16 @@ export function useClaimGasRefundRewards() {
return tx.hash as string
} catch (error) {
refetch()
- if (didUserReject(connector, error)) {
- notify({
- title: t`Transaction rejected`,
- summary: t`In order to claim, you must accept in your wallet.`,
- type: NotificationType.ERROR,
- })
- throw new Error('Transaction rejected.')
- } else {
- const message = formatWalletErrorMessage(error)
- console.error('Claim error:', { error, message })
- notify({
- title: t`Claim Error`,
- summary: message,
- type: NotificationType.ERROR,
- })
- throw error
- }
+ const message = friendlyError(error)
+ console.error('Claim error:', { message, error })
+ notify({
+ title: t`Claim Error`,
+ summary: message,
+ type: NotificationType.ERROR,
+ })
+ throw error
}
- }, [account, addTransactionWithType, chainId, claimableReward, library, notify, connector, refetch])
+ }, [account, addTransactionWithType, chainId, claimableReward, library, notify, refetch])
return claimGasRefundRewards
}
diff --git a/src/hooks/useApproveCallback.ts b/src/hooks/useApproveCallback.ts
index 8d3fe2c628..209daba3bd 100644
--- a/src/hooks/useApproveCallback.ts
+++ b/src/hooks/useApproveCallback.ts
@@ -1,15 +1,19 @@
import { MaxUint256 } from '@ethersproject/constants'
import { TransactionResponse } from '@ethersproject/providers'
import { Currency, CurrencyAmount, TokenAmount } from '@kyberswap/ks-sdk-core'
+import { t } from '@lingui/macro'
import JSBI from 'jsbi'
import { useCallback, useMemo } from 'react'
+import { NotificationType } from 'components/Announcement/type'
import { useTokenAllowance } from 'data/Allowances'
+import { useNotify } from 'state/application/hooks'
import { Field } from 'state/swap/actions'
import { useHasPendingApproval, useTransactionAdder } from 'state/transactions/hooks'
import { TRANSACTION_TYPE } from 'state/transactions/type'
import { calculateGasMargin } from 'utils'
import { Aggregator } from 'utils/aggregator'
+import { friendlyError } from 'utils/errorMessage'
import { computeSlippageAdjustedAmounts } from 'utils/prices'
import { useActiveWeb3React } from './index'
@@ -55,6 +59,7 @@ export function useApproveCallback(
: ApprovalState.NOT_APPROVED
: ApprovalState.APPROVED
}, [amountToApprove, currentAllowance, isSolana, pendingApproval, spender])
+ const notify = useNotify()
const tokenContract = useTokenContract(token?.address)
const addTransactionWithType = useTransactionAdder()
@@ -123,11 +128,20 @@ export function useApproveCallback(
})
})
.catch((error: Error) => {
- console.debug('Failed to approve token', error)
+ const message = friendlyError(error)
+ console.error('Approve token error:', { message, error })
+ notify(
+ {
+ title: t`Approve Error`,
+ summary: message,
+ type: NotificationType.ERROR,
+ },
+ 8000,
+ )
throw error
})
},
- [approvalState, token, tokenContract, amountToApprove, spender, addTransactionWithType, forceApprove],
+ [approvalState, token, tokenContract, amountToApprove, spender, addTransactionWithType, forceApprove, notify],
)
return [approvalState, approve, currentAllowance]
diff --git a/src/hooks/useElasticLegacy.ts b/src/hooks/useElasticLegacy.ts
index 465b472cf3..6699174773 100644
--- a/src/hooks/useElasticLegacy.ts
+++ b/src/hooks/useElasticLegacy.ts
@@ -8,6 +8,7 @@ import JSBI from 'jsbi'
import { useEffect, useRef, useState } from 'react'
import TickReaderABI from 'constants/abis/v2/ProAmmTickReader.json'
+import { didUserReject } from 'constants/connectors/utils'
import { EVMNetworkInfo } from 'constants/networks/type'
import { useActiveWeb3React, useWeb3React } from 'hooks'
import { useTransactionAdder } from 'state/transactions/hooks'
@@ -464,7 +465,7 @@ export const useRemoveLiquidityLegacy = (
setShowPendingModal('removeLiquidity')
setAttemptingTxn(false)
- if (error?.code !== 'ACTION_REJECTED') {
+ if (!didUserReject(error)) {
const e = new Error('Remove Legacy Elastic Liquidity Error', { cause: error })
e.name = ErrorName.RemoveElasticLiquidityError
captureException(e, {
diff --git a/src/hooks/useMixpanel.ts b/src/hooks/useMixpanel.ts
index 6f074f504f..d7e6ac6e7e 100644
--- a/src/hooks/useMixpanel.ts
+++ b/src/hooks/useMixpanel.ts
@@ -295,7 +295,6 @@ type FeeInfo = {
export default function useMixpanel(currencies?: { [field in Field]?: Currency }) {
const { chainId, account, isEVM, networkInfo } = useActiveWeb3React()
- const { isWhiteList } = useIsWhiteListKyberAI()
const { saveGas } = useSwapState()
const network = networkInfo.name
@@ -1336,105 +1335,9 @@ export default function useMixpanel(currencies?: { [field in Field]?: Currency }
break
}
}
-
- // Whitelist protected events
- if (isWhiteList) {
- switch (type) {
- case MIXPANEL_TYPE.KYBERAI_SHARE_TOKEN_CLICK: {
- mixpanel.track('KyberAI - Share token click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_GET_STARTED_CLICK: {
- mixpanel.track('KyberAI - Click Get Started', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_RANKING_SWITCH_CHAIN_CLICK: {
- mixpanel.track('KyberAI - Ranking - Switch chain click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_SEARCH_TOKEN_SUCCESS: {
- mixpanel.track('KyberAI - Search token success', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_SUBSCRIBE_CLICK: {
- mixpanel.track('KyberAI - Subscribe', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_RANKING_ACTION_CLICK: {
- mixpanel.track('KyberAI - Ranking - Action click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_ADD_TOKEN_TO_WATCHLIST: {
- mixpanel.track('KyberAI - Add token to watchlist', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_RANKING_CATEGORY_CLICK: {
- mixpanel.track('KyberAI - Ranking - Category click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_EXPLORING_SWAP_TOKEN_CLICK: {
- mixpanel.track('KyberAI - Exploring - Swap token click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_EXPLORING_VIEW_ALL_CLICK: {
- mixpanel.track('KyberAI - Exploring - View all click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_EXPLORING_ANALYSIS_TYPE_CLICK: {
- mixpanel.track('KyberAI - Exploring - Analysis type click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_EXPLORING_DISPLAY_SETTING_CLICK: {
- mixpanel.track('KyberAI - Exploring - Display setting click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_EXPLORING_CHANGE_DISPLAY_SETTING: {
- mixpanel.track('KyberAI - Exploring - Change display setting', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_EXPLORING_FULL_SCREEN_CLICK: {
- mixpanel.track('KyberAI - Exploring - Full screen click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_EXPLORING_SHARE_CHART_CLICK: {
- mixpanel.track('KyberAI - Exploring - Share chart click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_EXPLORING_SWITCH_TRADE_TYPE_CLICK: {
- mixpanel.track('KyberAI - Exploring - Switch trade type click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_EXPLORING_SWITCH_TIMEFRAME_CLICK: {
- mixpanel.track('KyberAI - Exploring - Switch timeframe click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_POOL_INSIGHT_CLICK: {
- mixpanel.track('KyberAI - Pool insight click', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_POOL_EXPLORE_TOKEN_IN_POPUP_INSIGHT: {
- mixpanel.track('KyberAI - Pool - Explore token on popup insight', payload)
- break
- }
- case MIXPANEL_TYPE.KYBERAI_EXPAND_WIDGET_CLICK: {
- mixpanel.track('KyberAI - Expand widget click', payload)
- break
- }
- default:
- break
- }
- }
},
/* eslint-disable */
- [
- currencies,
- network,
- saveGas,
- account,
- mixpanel.hasOwnProperty('get_distinct_id'),
- ethPrice?.currentPrice,
- isWhiteList,
- ],
+ [currencies, network, saveGas, account, mixpanel.hasOwnProperty('get_distinct_id'), ethPrice?.currentPrice],
/* eslint-enable */
)
const subgraphMixpanelHandler = useCallback(
@@ -1643,6 +1546,103 @@ export default function useMixpanel(currencies?: { [field in Field]?: Currency }
return { mixpanelHandler, subgraphMixpanelHandler }
}
+export const useMixpanelKyberAI = () => {
+ const { isWhiteList } = useIsWhiteListKyberAI()
+ const mixpanelHandler = useCallback(
+ (type: MIXPANEL_TYPE, payload?: any) => {
+ // Whitelist protected events
+ if (isWhiteList) {
+ switch (type) {
+ case MIXPANEL_TYPE.KYBERAI_SHARE_TOKEN_CLICK: {
+ mixpanel.track('KyberAI - Share token click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_GET_STARTED_CLICK: {
+ mixpanel.track('KyberAI - Click Get Started', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_RANKING_SWITCH_CHAIN_CLICK: {
+ mixpanel.track('KyberAI - Ranking - Switch chain click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_SEARCH_TOKEN_SUCCESS: {
+ mixpanel.track('KyberAI - Search token success', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_SUBSCRIBE_CLICK: {
+ mixpanel.track('KyberAI - Subscribe', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_RANKING_ACTION_CLICK: {
+ mixpanel.track('KyberAI - Ranking - Action click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_ADD_TOKEN_TO_WATCHLIST: {
+ mixpanel.track('KyberAI - Add token to watchlist', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_RANKING_CATEGORY_CLICK: {
+ mixpanel.track('KyberAI - Ranking - Category click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_EXPLORING_SWAP_TOKEN_CLICK: {
+ mixpanel.track('KyberAI - Exploring - Swap token click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_EXPLORING_VIEW_ALL_CLICK: {
+ mixpanel.track('KyberAI - Exploring - View all click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_EXPLORING_ANALYSIS_TYPE_CLICK: {
+ mixpanel.track('KyberAI - Exploring - Analysis type click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_EXPLORING_DISPLAY_SETTING_CLICK: {
+ mixpanel.track('KyberAI - Exploring - Display setting click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_EXPLORING_CHANGE_DISPLAY_SETTING: {
+ mixpanel.track('KyberAI - Exploring - Change display setting', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_EXPLORING_FULL_SCREEN_CLICK: {
+ mixpanel.track('KyberAI - Exploring - Full screen click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_EXPLORING_SHARE_CHART_CLICK: {
+ mixpanel.track('KyberAI - Exploring - Share chart click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_EXPLORING_SWITCH_TRADE_TYPE_CLICK: {
+ mixpanel.track('KyberAI - Exploring - Switch trade type click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_EXPLORING_SWITCH_TIMEFRAME_CLICK: {
+ mixpanel.track('KyberAI - Exploring - Switch timeframe click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_POOL_INSIGHT_CLICK: {
+ mixpanel.track('KyberAI - Pool insight click', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_POOL_EXPLORE_TOKEN_IN_POPUP_INSIGHT: {
+ mixpanel.track('KyberAI - Pool - Explore token on popup insight', payload)
+ break
+ }
+ case MIXPANEL_TYPE.KYBERAI_EXPAND_WIDGET_CLICK: {
+ mixpanel.track('KyberAI - Expand widget click', payload)
+ break
+ }
+ default:
+ break
+ }
+ }
+ },
+ [isWhiteList],
+ )
+ return mixpanelHandler
+}
+
export const useGlobalMixpanelEvents = () => {
const { account, chainId, isEVM } = useActiveWeb3React()
const { mixpanelHandler } = useMixpanel()
diff --git a/src/hooks/web3/useChangeNetwork.ts b/src/hooks/web3/useChangeNetwork.ts
index 7db7db477f..3039ecb17f 100644
--- a/src/hooks/web3/useChangeNetwork.ts
+++ b/src/hooks/web3/useChangeNetwork.ts
@@ -1,7 +1,6 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
import { t } from '@lingui/macro'
import { captureException } from '@sentry/react'
-import { Connector } from '@web3-react/types'
import { useCallback } from 'react'
import { NotificationType } from 'components/Announcement/type'
@@ -57,10 +56,9 @@ export function useChangeNetwork() {
const failureCallback = useCallback(
(
- connector: Connector,
desiredChainId: ChainId,
error: any,
- customFailureCallback?: (connector: Connector, error: Error) => void,
+ customFailureCallback?: (error: Error) => void,
customTexts?: {
name?: string
title?: string
@@ -71,7 +69,7 @@ export function useChangeNetwork() {
const title = customTexts?.title || t`Failed to switch network`
let message: string = customTexts?.default || t`Error when changing network.`
- if (didUserReject(connector, error)) {
+ if (didUserReject(error)) {
message =
customTexts?.rejected ||
t`In order to use KyberSwap on ${
@@ -99,7 +97,7 @@ export function useChangeNetwork() {
type: NotificationType.ERROR,
summary: message,
})
- customFailureCallback?.(connector, error)
+ customFailureCallback?.(error)
},
[chainId, notify, walletEVM.walletKey],
)
@@ -115,7 +113,7 @@ export function useChangeNetwork() {
default?: string
},
customSuccessCallback?: () => void,
- customFailureCallback?: (connector: Connector, error: Error) => void,
+ customFailureCallback?: (error: Error) => void,
waitUtilUpdatedChainId = false,
) => {
const wrappedSuccessCallback = () =>
@@ -144,8 +142,8 @@ export function useChangeNetwork() {
wrappedSuccessCallback()
} catch (error) {
console.error('Add new network failed', { addChainParameter, error })
- failureCallback(connector, desiredChainId, error, customFailureCallback, customTexts)
- if (!didUserReject(connector, error)) {
+ failureCallback(desiredChainId, error, customFailureCallback, customTexts)
+ if (!didUserReject(error)) {
const e = new Error(`[Wallet] ${error.message}`)
e.name = 'Add new network Error'
e.stack = ''
@@ -157,22 +155,14 @@ export function useChangeNetwork() {
}
}
},
- [
- library?.provider,
- chainId,
- connector,
- failureCallback,
- fetchKyberswapConfig,
- successCallback,
- walletEVM.walletKey,
- ],
+ [library?.provider, chainId, failureCallback, fetchKyberswapConfig, successCallback, walletEVM.walletKey],
)
const changeNetwork = useCallback(
async (
desiredChainId: ChainId,
customSuccessCallback?: () => void,
- customFailureCallback?: (connector: Connector, error: Error) => void,
+ customFailureCallback?: (error: Error) => void,
waitUtilUpdatedChainId = false,
isAddNetworkIfPossible = true,
) => {
@@ -203,8 +193,8 @@ export function useChangeNetwork() {
console.error('Switch network failed', { desiredChainId, error })
// walletconnect v2 not support add network, so halt execution here
- if (didUserReject(connector, error) || connector === walletConnectV2) {
- failureCallback(connector, desiredChainId, error, customFailureCallback)
+ if (didUserReject(error) || connector === walletConnectV2) {
+ failureCallback(desiredChainId, error, customFailureCallback)
return
}
if (isAddNetworkIfPossible) {
@@ -224,7 +214,7 @@ export function useChangeNetwork() {
waitUtilUpdatedChainId,
)
} else {
- failureCallback(connector, desiredChainId, error, customFailureCallback)
+ failureCallback(desiredChainId, error, customFailureCallback)
}
}
} else {
diff --git a/src/pages/About/AboutKyberSwap/index.tsx b/src/pages/About/AboutKyberSwap/index.tsx
index 7b6fe7df11..c192e0ded4 100644
--- a/src/pages/About/AboutKyberSwap/index.tsx
+++ b/src/pages/About/AboutKyberSwap/index.tsx
@@ -30,37 +30,24 @@ import Banner from 'components/Banner'
import { ButtonEmpty, ButtonLight } from 'components/Button'
import { FooterSocialLink } from 'components/Footer/Footer'
import {
- Arbitrum,
- Aurora,
AuroraFull,
- Avalanche,
BestPrice,
- Binance,
- Bttc,
CircleFocus,
Clock,
- Cronos,
CronosLogoFull,
Drop,
Enter,
- Ethereum,
- Fantom,
FantomLogoFull,
FarmIcon,
LineaFull,
LowestSlippage,
MoneyBagOutline,
- Oasis,
OasisLogoFull,
- OptimismLogo,
OptimismLogoFull,
- Polygon,
PolygonLogoFull,
- Velas,
VelasLogoFull,
} from 'components/Icons'
import AntiSnippingAttack from 'components/Icons/AntiSnippingAttack'
-import ZkSync from 'components/Icons/ZkSync'
import ZkSyncFull from 'components/Icons/ZkSyncFull'
import Loader from 'components/Loader'
import { APP_PATHS } from 'constants/index'
@@ -510,21 +497,19 @@ function AboutKyberSwap() {
-
-
-
-
-
-
-
-
-
-
-
-
- {/* */}
-
-
+ {MAINNET_NETWORKS.map(chain => (
+
+ ))}
@@ -1046,6 +1031,15 @@ function AboutKyberSwap() {
{/* */}
+
diff --git a/src/pages/AddLiquidity/TokenPair.tsx b/src/pages/AddLiquidity/TokenPair.tsx
index 0862bdafd8..1537a891bb 100644
--- a/src/pages/AddLiquidity/TokenPair.tsx
+++ b/src/pages/AddLiquidity/TokenPair.tsx
@@ -23,6 +23,7 @@ import TransactionConfirmationModal, {
ConfirmationModalContent,
TransactionErrorContent,
} from 'components/TransactionConfirmationModal'
+import { didUserReject } from 'constants/connectors/utils'
import { AMP_HINT, APP_PATHS } from 'constants/index'
import { EVMNetworkInfo } from 'constants/networks/type'
import { NativeCurrencies } from 'constants/tokens'
@@ -315,7 +316,7 @@ const TokenPair = ({
e.name = 'AddLiquidityError'
captureException(e, { extra: { args } })
// we only care if the error is something _other_ than the user rejected the tx
- if (err?.code !== 4001) {
+ if (!didUserReject(error)) {
console.error(err)
}
diff --git a/src/pages/AddLiquidity/ZapIn.tsx b/src/pages/AddLiquidity/ZapIn.tsx
index 976f8982b8..5d61485169 100644
--- a/src/pages/AddLiquidity/ZapIn.tsx
+++ b/src/pages/AddLiquidity/ZapIn.tsx
@@ -25,6 +25,7 @@ import TransactionConfirmationModal, {
} from 'components/TransactionConfirmationModal'
import ZapError from 'components/ZapError'
import FormattedPriceImpact from 'components/swapv2/FormattedPriceImpact'
+import { didUserReject } from 'constants/connectors/utils'
import { AMP_HINT, APP_PATHS } from 'constants/index'
import { EVMNetworkInfo } from 'constants/networks/type'
import { NativeCurrencies } from 'constants/tokens'
@@ -283,7 +284,7 @@ const ZapIn = ({
captureException(e, { extra: { args } })
// we only care if the error is something _other_ than the user rejected the tx
- if (err?.code !== 4001) {
+ if (!didUserReject(err)) {
console.error(err)
}
diff --git a/src/pages/AddLiquidityV2/index.tsx b/src/pages/AddLiquidityV2/index.tsx
index 4c50d73999..f6c63843f8 100644
--- a/src/pages/AddLiquidityV2/index.tsx
+++ b/src/pages/AddLiquidityV2/index.tsx
@@ -19,6 +19,7 @@ import { useMedia } from 'react-use'
import { Box, Flex, Text } from 'rebass'
import styled from 'styled-components'
+import { NotificationType } from 'components/Announcement/type'
import { ButtonError, ButtonLight, ButtonPrimary } from 'components/Button'
import { OutlineCard, SubTextCard, WarningCard } from 'components/Card'
import { AutoColumn } from 'components/Column'
@@ -62,7 +63,7 @@ import useTheme from 'hooks/useTheme'
import useTransactionDeadline from 'hooks/useTransactionDeadline'
import { convertTickToPrice } from 'pages/Farm/ElasticFarmv2/utils'
import { ApplicationModal } from 'state/application/actions'
-import { useOpenModal, useWalletModalToggle } from 'state/application/hooks'
+import { useNotify, useOpenModal, useWalletModalToggle } from 'state/application/hooks'
import { FarmUpdater } from 'state/farms/elastic/hooks'
import { useElasticFarmsV2 } from 'state/farms/elasticv2/hooks'
import ElasticFarmV2Updater from 'state/farms/elasticv2/updater'
@@ -85,6 +86,7 @@ import { VIEW_MODE } from 'state/user/reducer'
import { ExternalLink, MEDIA_WIDTHS, StyledInternalLink, TYPE } from 'theme'
import { basisPointsToPercent, calculateGasMargin, formattedNum } from 'utils'
import { currencyId } from 'utils/currencyId'
+import { friendlyError } from 'utils/errorMessage'
import { toSignificantOrMaxIntegerPart } from 'utils/formatCurrencyAmount'
import { maxAmountSpend } from 'utils/maxAmountSpend'
import { formatNotDollarAmount } from 'utils/numbers'
@@ -139,6 +141,7 @@ export default function AddLiquidity() {
const [showChart, setShowChart] = useState(false)
const [positionIndex, setPositionIndex] = useState(0)
const { mixpanelHandler } = useMixpanel()
+ const notify = useNotify()
// fee selection from url
const feeAmount: FeeAmount =
@@ -212,9 +215,10 @@ export default function AddLiquidity() {
// show this for Zohar can get tick to add farm
useEffect(() => {
- console.log('-------------------')
- console.log('tickLower: ', tickLower)
- console.log('tickUpper: ', tickUpper)
+ console.groupCollapsed('ticks ------------------')
+ console.debug('tickLower: ', tickLower)
+ console.debug('tickUpper: ', tickUpper)
+ console.groupEnd()
}, [tickLower, tickUpper])
const poolAddress = useProAmmPoolInfo(baseCurrency, currencyB, feeAmount)
@@ -498,12 +502,18 @@ export default function AddLiquidity() {
})
})
.catch((error: any) => {
- console.error('Failed to send transaction', error)
setAttemptingTxn(false)
- // we only care if the error is something _other_ than the user rejected the tx
- if (error?.code !== 4001) {
- console.error(error)
- }
+ // sending tx error, not tx execute error
+ const message = friendlyError(error)
+ console.error('Add liquidity error:', { message, error })
+ notify(
+ {
+ title: t`Add liquidity error`,
+ summary: message,
+ type: NotificationType.ERROR,
+ },
+ 8000,
+ )
})
} else {
return
@@ -530,6 +540,7 @@ export default function AddLiquidity() {
isMultiplePosition,
poolAddress,
currencyAmountSum,
+ notify,
],
)
diff --git a/src/pages/CreatePool/index.tsx b/src/pages/CreatePool/index.tsx
index 4e0dba71d7..4ebaae0698 100644
--- a/src/pages/CreatePool/index.tsx
+++ b/src/pages/CreatePool/index.tsx
@@ -21,6 +21,7 @@ import QuestionHelper from 'components/QuestionHelper'
import Row, { AutoRow, RowBetween, RowFlat } from 'components/Row'
import TransactionConfirmationModal, { ConfirmationModalContent } from 'components/TransactionConfirmationModal'
import { TutorialType } from 'components/Tutorial'
+import { didUserReject } from 'constants/connectors/utils'
import { APP_PATHS, CREATE_POOL_AMP_HINT } from 'constants/index'
import { ONLY_DYNAMIC_FEE_CHAINS, ONLY_STATIC_FEE_CHAINS, STATIC_FEE_OPTIONS } from 'constants/networks'
import { EVMNetworkInfo } from 'constants/networks/type'
@@ -287,7 +288,7 @@ export default function CreatePool() {
setAttemptingTxn(false)
setShowConfirm(false)
// we only care if the error is something _other_ than the user rejected the tx
- if (error?.code !== 4001) {
+ if (!didUserReject(error)) {
console.error(error)
}
})
@@ -296,7 +297,7 @@ export default function CreatePool() {
setAttemptingTxn(false)
setShowConfirm(false)
// we only care if the error is something _other_ than the user rejected the tx
- if (error?.code !== 4001) {
+ if (!didUserReject(error)) {
console.error(error)
}
})
diff --git a/src/pages/ElasticSwap/hooks/index.ts b/src/pages/ElasticSwap/hooks/index.ts
index 061a8a66f7..5ed0b37867 100644
--- a/src/pages/ElasticSwap/hooks/index.ts
+++ b/src/pages/ElasticSwap/hooks/index.ts
@@ -6,6 +6,7 @@ import { useMemo } from 'react'
import { useSearchParams } from 'react-router-dom'
import { abi as QuoterABI } from 'constants/abis/v2/ProAmmQuoter.json'
+import { didUserReject } from 'constants/connectors/utils'
import { INITIAL_ALLOWED_SLIPPAGE } from 'constants/index'
import { EVMNetworkInfo } from 'constants/networks/type'
import { useActiveWeb3React, useWeb3React } from 'hooks'
@@ -555,7 +556,7 @@ export function useSwapCallback(
})
.catch((error: any) => {
// if the user rejected the tx, pass this along
- if (error?.code === 4001) {
+ if (didUserReject(error)) {
throw new Error('Transaction rejected.')
} else {
// otherwise, the error was unexpected and we need to convey that
diff --git a/src/pages/IncreaseLiquidity/index.tsx b/src/pages/IncreaseLiquidity/index.tsx
index 3e88c2c4ad..6d53224488 100644
--- a/src/pages/IncreaseLiquidity/index.tsx
+++ b/src/pages/IncreaseLiquidity/index.tsx
@@ -30,6 +30,7 @@ import { RowBetween } from 'components/Row'
import { SLIPPAGE_EXPLANATION_URL } from 'components/SlippageWarningNote'
import TransactionConfirmationModal, { ConfirmationModalContent } from 'components/TransactionConfirmationModal'
import { TutorialType } from 'components/Tutorial'
+import { didUserReject } from 'constants/connectors/utils'
import { APP_PATHS } from 'constants/index'
import { EVMNetworkInfo } from 'constants/networks/type'
import { NativeCurrencies } from 'constants/tokens'
@@ -310,7 +311,7 @@ export default function IncreaseLiquidity() {
console.error('Failed to send transaction', error)
setAttemptingTxn(false)
// we only care if the error is something _other_ than the user rejected the tx
- if (error?.code !== 4001) {
+ if (!didUserReject(error)) {
console.error(error)
}
})
diff --git a/src/pages/MyEarnings/hooks.ts b/src/pages/MyEarnings/hooks.ts
index 33656dbbbf..1914cdbcbd 100644
--- a/src/pages/MyEarnings/hooks.ts
+++ b/src/pages/MyEarnings/hooks.ts
@@ -9,6 +9,7 @@ import { useEffect, useMemo, useRef, useState } from 'react'
import { useDispatch } from 'react-redux'
import { POOLS_BULK_WITH_PAGINATION, POOLS_HISTORICAL_BULK_WITH_PAGINATION, POOL_COUNT } from 'apollo/queries'
+import { didUserReject } from 'constants/connectors/utils'
import { NETWORKS_INFO, ONLY_DYNAMIC_FEE_CHAINS, isEVM as isEVMChain } from 'constants/networks'
import { useActiveWeb3React, useWeb3React } from 'hooks'
import { Position as SubgraphLegacyPosition, config, parsePosition } from 'hooks/useElasticLegacy'
@@ -360,7 +361,7 @@ export function useRemoveLiquidityFromLegacyPosition(
dispatch(setShowPendingModal(MODAL_PENDING_TEXTS.REMOVE_LIQUIDITY))
dispatch(setAttemptingTxn(false))
- if (error?.code !== 'ACTION_REJECTED') {
+ if (!didUserReject(error)) {
const e = new Error('Remove Legacy Elastic Liquidity Error', { cause: error })
e.name = ErrorName.RemoveElasticLiquidityError
captureException(e, {
diff --git a/src/pages/ProAmmPools/KyberAIModalInPool.tsx b/src/pages/ProAmmPools/KyberAIModalInPool.tsx
index e0dc6507ec..a2bfdee408 100644
--- a/src/pages/ProAmmPools/KyberAIModalInPool.tsx
+++ b/src/pages/ProAmmPools/KyberAIModalInPool.tsx
@@ -14,7 +14,7 @@ import Row, { RowBetween, RowFit } from 'components/Row'
import { MouseoverTooltip } from 'components/Tooltip'
import { APP_PATHS } from 'constants/index'
import { useActiveWeb3React } from 'hooks'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import useTheme from 'hooks/useTheme'
import KyberScoreMeter from 'pages/TrueSightV2/components/KyberScoreMeter'
import SimpleTooltip from 'pages/TrueSightV2/components/SimpleTooltip'
@@ -94,7 +94,7 @@ const enum TokenTabType {
const KyberAIModalInPool = ({ currency0, currency1 }: { currency0?: Currency; currency1?: Currency }) => {
const theme = useTheme()
const { chainId } = useActiveWeb3React()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const { isWhiteList } = useIsWhiteListKyberAI()
const [tab, setTab] = useState(TokenTabType.First)
const [openTruesightModal, setOpenTruesightModal] = useState(false)
diff --git a/src/pages/RemoveLiquidity/TokenPair.tsx b/src/pages/RemoveLiquidity/TokenPair.tsx
index 2a55a89bb2..a1cf53837a 100644
--- a/src/pages/RemoveLiquidity/TokenPair.tsx
+++ b/src/pages/RemoveLiquidity/TokenPair.tsx
@@ -24,6 +24,7 @@ import TransactionConfirmationModal, {
ConfirmationModalContent,
TransactionErrorContent,
} from 'components/TransactionConfirmationModal'
+import { didUserReject } from 'constants/connectors/utils'
import { APP_PATHS, EIP712Domain } from 'constants/index'
import { EVMNetworkInfo } from 'constants/networks/type'
import { NativeCurrencies } from 'constants/tokens'
@@ -204,7 +205,7 @@ export default function TokenPair({
})
.catch((error: any) => {
// for all errors other than 4001 (EIP-1193 user rejected request), fall back to manual approve
- if (error?.code !== 4001) {
+ if (!didUserReject(error)) {
approveCallback()
}
})
@@ -397,7 +398,7 @@ export default function TokenPair({
.catch((err: Error) => {
setAttemptingTxn(false)
// we only care if the error is something _other_ than the user rejected the tx
- if ((err as any)?.code !== 4001 && (err as any)?.code !== 'ACTION_REJECTED') {
+ if (!didUserReject(err)) {
const e = new Error('Remove Classic Liquidity Error', { cause: err })
e.name = ErrorName.RemoveClassicLiquidityError
captureException(e, { extra: { args } })
diff --git a/src/pages/RemoveLiquidity/ZapOut.tsx b/src/pages/RemoveLiquidity/ZapOut.tsx
index 15f2d6f892..532f19021f 100644
--- a/src/pages/RemoveLiquidity/ZapOut.tsx
+++ b/src/pages/RemoveLiquidity/ZapOut.tsx
@@ -35,6 +35,7 @@ import TransactionConfirmationModal, {
} from 'components/TransactionConfirmationModal'
import ZapError from 'components/ZapError'
import FormattedPriceImpact from 'components/swapv2/FormattedPriceImpact'
+import { didUserReject } from 'constants/connectors/utils'
import { APP_PATHS, EIP712Domain } from 'constants/index'
import { EVMNetworkInfo } from 'constants/networks/type'
import { NativeCurrencies } from 'constants/tokens'
@@ -246,7 +247,7 @@ export default function ZapOut({
})
.catch((error: any) => {
// for all errors other than 4001 (EIP-1193 user rejected request), fall back to manual approve
- if (error?.code !== 4001) {
+ if (!didUserReject(error)) {
approveCallback()
}
})
@@ -370,7 +371,7 @@ export default function ZapOut({
.then(calculateGasMargin)
.catch(err => {
// we only care if the error is something other than the user rejected the tx
- if ((err as any)?.code !== 4001) {
+ if (!didUserReject(err)) {
console.error(`estimateGas failed`, methodName, args, err)
}
@@ -381,7 +382,7 @@ export default function ZapOut({
setZapOutError(t`Insufficient Liquidity in the Liquidity Pool to Swap`)
} else {
setZapOutError(err?.message)
- if ((err as any)?.code !== 4001 && (err as any)?.code !== 'ACTION_REJECTED') {
+ if (!didUserReject(err)) {
const e = new Error('estimate gas zap out failed', { cause: err })
e.name = ErrorName.RemoveClassicLiquidityError
captureException(e, { extra: { args } })
@@ -441,7 +442,7 @@ export default function ZapOut({
.catch((err: Error) => {
setAttemptingTxn(false)
// we only care if the error is something _other_ than the user rejected the tx
- if ((err as any)?.code !== 4001 && (err as any)?.code !== 'ACTION_REJECTED') {
+ if (!didUserReject(err)) {
const e = new Error('zap out failed', { cause: err })
e.name = ErrorName.RemoveClassicLiquidityError
captureException(e, { extra: { args } })
diff --git a/src/pages/RemoveLiquidityProAmm/index.tsx b/src/pages/RemoveLiquidityProAmm/index.tsx
index 13d643a2e9..fc679f9d45 100644
--- a/src/pages/RemoveLiquidityProAmm/index.tsx
+++ b/src/pages/RemoveLiquidityProAmm/index.tsx
@@ -37,6 +37,7 @@ import TransactionConfirmationModal, {
} from 'components/TransactionConfirmationModal'
import { TutorialType } from 'components/Tutorial'
import FarmV2ABI from 'constants/abis/v2/farmv2.json'
+import { didUserReject } from 'constants/connectors/utils'
import { EVMNetworkInfo } from 'constants/networks/type'
import { useActiveWeb3React, useWeb3React } from 'hooks'
import { useContract, useProAmmNFTPositionManagerContract, useProMMFarmContract } from 'hooks/useContract'
@@ -416,7 +417,7 @@ function Remove({ tokenId }: { tokenId: BigNumber }) {
.catch((error: any) => {
setAttemptingTxn(false)
- if (error?.code !== 'ACTION_REJECTED') {
+ if (!didUserReject(error)) {
const e = new Error('Remove Elastic Liquidity Error', { cause: error })
e.name = ErrorName.RemoveElasticLiquidityError
captureException(e, {
diff --git a/src/pages/SwapV2/index.tsx b/src/pages/SwapV2/index.tsx
index c63a965911..86562c686d 100644
--- a/src/pages/SwapV2/index.tsx
+++ b/src/pages/SwapV2/index.tsx
@@ -311,7 +311,7 @@ export default function Swap() {
setSwapState({ attemptingTxn: false, tradeToConfirm, showConfirm, swapErrorMessage: undefined, txHash: hash })
})
.catch(error => {
- if (error?.code !== 4001 && error?.code !== 'ACTION_REJECTED') captureSwapError(error)
+ captureSwapError(error)
setSwapState({
attemptingTxn: false,
tradeToConfirm,
diff --git a/src/pages/TrueSightV2/components/DisplaySettings.tsx b/src/pages/TrueSightV2/components/DisplaySettings.tsx
index f575380593..a538e47723 100644
--- a/src/pages/TrueSightV2/components/DisplaySettings.tsx
+++ b/src/pages/TrueSightV2/components/DisplaySettings.tsx
@@ -12,7 +12,7 @@ import Icon from 'components/Icons/Icon'
import Popover from 'components/Popover'
import { RowBetween, RowFit } from 'components/Row'
import Toggle from 'components/Toggle'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import { useOnClickOutside } from 'hooks/useOnClickOutside'
import useTheme from 'hooks/useTheme'
import { ApplicationModal } from 'state/application/actions'
@@ -105,7 +105,7 @@ const technicalAnalysisSettings = [
export default function DisplaySettings({ currentTab }: { currentTab: DiscoverTokenTab }) {
const theme = useTheme()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const [showSettings, setShowSettings] = useState(false)
const [showOnchainSetting, setShowOnchainSetting] = useState(currentTab === DiscoverTokenTab.OnChainAnalysis)
const [showTechnicalSetting, setShowTechnicalSetting] = useState(currentTab === DiscoverTokenTab.TechnicalAnalysis)
diff --git a/src/pages/TrueSightV2/components/KyberAIWidget.tsx b/src/pages/TrueSightV2/components/KyberAIWidget.tsx
index 262fa79fc6..37e77c908b 100644
--- a/src/pages/TrueSightV2/components/KyberAIWidget.tsx
+++ b/src/pages/TrueSightV2/components/KyberAIWidget.tsx
@@ -16,7 +16,7 @@ import Row, { RowBetween } from 'components/Row'
import { MouseoverTooltip } from 'components/Tooltip'
import { APP_PATHS } from 'constants/index'
import { useActiveWeb3React } from 'hooks'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import { useOnClickOutside } from 'hooks/useOnClickOutside'
import useTheme from 'hooks/useTheme'
import { useIsWhiteListKyberAI, useKyberAIWidget } from 'state/user/hooks'
@@ -179,7 +179,7 @@ const widgetTabTooltip = {
export default function Widget() {
const { account } = useActiveWeb3React()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const theme = useTheme()
const [showExpanded, setShowExpanded] = useState(false)
const [showWidget, toggleWidget] = useKyberAIWidget()
diff --git a/src/pages/TrueSightV2/components/SearchWithDropDown.tsx b/src/pages/TrueSightV2/components/SearchWithDropDown.tsx
index f0b558425c..a543996385 100644
--- a/src/pages/TrueSightV2/components/SearchWithDropDown.tsx
+++ b/src/pages/TrueSightV2/components/SearchWithDropDown.tsx
@@ -13,7 +13,7 @@ import Icon from 'components/Icons/Icon'
import Row, { RowFit } from 'components/Row'
import { APP_PATHS } from 'constants/index'
import useDebounce from 'hooks/useDebounce'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import { useOnClickOutside } from 'hooks/useOnClickOutside'
import useTheme from 'hooks/useTheme'
import { MEDIA_WIDTHS } from 'theme'
@@ -304,7 +304,7 @@ const SearchResultTableWrapper = ({ header, children }: { header?: ReactNode; ch
let checkedNewData = false
const SearchWithDropdown = () => {
const theme = useTheme()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const [searchParams] = useSearchParams()
const { pathname } = useLocation()
diff --git a/src/pages/TrueSightV2/components/TimeFrameLegend.tsx b/src/pages/TrueSightV2/components/TimeFrameLegend.tsx
index ca77e0c8a4..118d528579 100644
--- a/src/pages/TrueSightV2/components/TimeFrameLegend.tsx
+++ b/src/pages/TrueSightV2/components/TimeFrameLegend.tsx
@@ -1,7 +1,7 @@
import React, { useLayoutEffect, useRef, useState } from 'react'
import styled, { css } from 'styled-components'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import useKyberAITokenOverview from '../hooks/useKyberAITokenOverview'
import { KyberAITimeframe } from '../types'
@@ -66,7 +66,7 @@ const TimeFrameLegend = ({
timeframes: KyberAITimeframe[]
onSelect: (timeframe: KyberAITimeframe) => void
}) => {
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const refs = useRef({})
const ref = useRef(null)
const [left, setLeft] = useState(0)
diff --git a/src/pages/TrueSightV2/components/TokenOverview.tsx b/src/pages/TrueSightV2/components/TokenOverview.tsx
index b3eaaec17d..27324dc590 100644
--- a/src/pages/TrueSightV2/components/TokenOverview.tsx
+++ b/src/pages/TrueSightV2/components/TokenOverview.tsx
@@ -14,7 +14,7 @@ import Icon from 'components/Icons/Icon'
import { DotsLoader } from 'components/Loader/DotsLoader'
import Row, { RowBetween, RowFit } from 'components/Row'
import { MouseoverTooltip } from 'components/Tooltip'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import useTheme from 'hooks/useTheme'
import { MEDIA_WIDTHS } from 'theme'
import { getEtherscanLink, shortenAddress } from 'utils'
@@ -146,7 +146,7 @@ const ExternalLink = ({ href, className, children }: { href: string; className?:
export const TokenOverview = ({ data, isLoading }: { data?: ITokenOverview; isLoading?: boolean }) => {
const theme = useTheme()
const { chain } = useParams()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const above768 = useMedia(`(min-width:${MEDIA_WIDTHS.upToSmall}px)`)
const [expanded, setExpanded] = useState(false)
const [showShare, setShowShare] = useState(false)
diff --git a/src/pages/TrueSightV2/components/index.tsx b/src/pages/TrueSightV2/components/index.tsx
index 6361887305..fbfe9068b5 100644
--- a/src/pages/TrueSightV2/components/index.tsx
+++ b/src/pages/TrueSightV2/components/index.tsx
@@ -11,7 +11,7 @@ import Icon from 'components/Icons/Icon'
import Modal from 'components/Modal'
import Row, { RowBetween, RowFit } from 'components/Row'
import { MouseoverTooltip } from 'components/Tooltip'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import useTheme from 'hooks/useTheme'
import { CloseIcon, MEDIA_WIDTHS } from 'theme'
import { openFullscreen } from 'utils/index'
@@ -141,7 +141,7 @@ export const SectionWrapper = ({
style?: React.CSSProperties
}) => {
const theme = useTheme()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const { chain } = useParams()
const { data: token } = useKyberAITokenOverview()
const ref = useRef(null)
diff --git a/src/pages/TrueSightV2/components/table/index.tsx b/src/pages/TrueSightV2/components/table/index.tsx
index 72d73dfd80..aac6929720 100644
--- a/src/pages/TrueSightV2/components/table/index.tsx
+++ b/src/pages/TrueSightV2/components/table/index.tsx
@@ -19,7 +19,7 @@ import Pagination from 'components/Pagination'
import Row, { RowFit } from 'components/Row'
import { APP_PATHS } from 'constants/index'
import { useActiveWeb3React } from 'hooks'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import { useOnClickOutside } from 'hooks/useOnClickOutside'
import useTheme from 'hooks/useTheme'
import { NETWORK_IMAGE_URL, NETWORK_TO_CHAINID } from 'pages/TrueSightV2/constants'
@@ -587,7 +587,7 @@ const WidgetTokenRow = ({
const theme = useTheme()
const navigate = useNavigate()
const { account } = useActiveWeb3React()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const reachedMaxLimit = useIsReachMaxLimitWatchedToken(token?.tokens.length)
const latestKyberScore: IKyberScoreChart | undefined = token?.ks_3d?.[token.ks_3d.length - 1]
diff --git a/src/pages/TrueSightV2/index.tsx b/src/pages/TrueSightV2/index.tsx
index 5fd250f85c..ec537a5d04 100644
--- a/src/pages/TrueSightV2/index.tsx
+++ b/src/pages/TrueSightV2/index.tsx
@@ -12,7 +12,7 @@ import SubscribeNotificationButton from 'components/SubscribeButton'
import { MouseoverTooltip } from 'components/Tooltip'
import { KYBER_AI_TOPIC_ID } from 'constants/env'
import { APP_PATHS } from 'constants/index'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import useTheme from 'hooks/useTheme'
import { MEDIA_WIDTHS } from 'theme'
@@ -77,7 +77,7 @@ const HeaderNavItem = styled.div<{ active?: boolean }>`
export default function TrueSightV2() {
const theme = useTheme()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const location = useLocation()
const isExplore = location?.pathname.includes('Explore')
const above768 = useMedia(`(min-width:${MEDIA_WIDTHS.upToSmall}px)`)
diff --git a/src/pages/TrueSightV2/pages/RegisterWhitelist/index.tsx b/src/pages/TrueSightV2/pages/RegisterWhitelist/index.tsx
index 102b2ffb12..939dce6e67 100644
--- a/src/pages/TrueSightV2/pages/RegisterWhitelist/index.tsx
+++ b/src/pages/TrueSightV2/pages/RegisterWhitelist/index.tsx
@@ -9,7 +9,7 @@ import { ButtonPrimary } from 'components/Button'
import { APP_PATHS } from 'constants/index'
import { useActiveWeb3React } from 'hooks'
import useLogin from 'hooks/useLogin'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import useTheme from 'hooks/useTheme'
import SubscribeForm from 'pages/TrueSightV2/pages/RegisterWhitelist/SubscribeForm'
import WaitListForm from 'pages/TrueSightV2/pages/RegisterWhitelist/WaitListForm'
@@ -26,7 +26,7 @@ const ConnectWalletButton = styled(ButtonPrimary)`
export default function RegisterWhitelist({ showForm = true }: { showForm?: boolean }) {
const navigate = useNavigate()
const theme = useTheme()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const { account } = useActiveWeb3React()
const toggleWalletModal = useWalletModalToggle()
const { isLogin } = useSessionInfo()
diff --git a/src/pages/TrueSightV2/pages/SingleToken.tsx b/src/pages/TrueSightV2/pages/SingleToken.tsx
index fb7c97b525..7d316b3d43 100644
--- a/src/pages/TrueSightV2/pages/SingleToken.tsx
+++ b/src/pages/TrueSightV2/pages/SingleToken.tsx
@@ -14,7 +14,7 @@ import { DotsLoader } from 'components/Loader/DotsLoader'
import Row, { RowBetween, RowFit } from 'components/Row'
import { APP_PATHS } from 'constants/index'
import { useActiveWeb3React } from 'hooks'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import useTheme from 'hooks/useTheme'
import { PROFILE_MANAGE_ROUTES } from 'pages/NotificationCenter/const'
import { MEDIA_WIDTHS } from 'theme'
@@ -235,7 +235,7 @@ const TokenDescription = ({ description }: { description: string }) => {
const TokenNameGroup = ({ token, isLoading }: { token?: ITokenOverview; isLoading?: boolean }) => {
const { account } = useActiveWeb3React()
const theme = useTheme()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const navigate = useNavigate()
const location = useLocation()
const above768 = useMedia(`(min-width:${MEDIA_WIDTHS.upToSmall}px)`)
@@ -442,7 +442,7 @@ const TokenHeader = ({
isLoading?: boolean
onShareClick: () => void
}) => {
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const above768 = useMedia(`(min-width:${MEDIA_WIDTHS.upToSmall}px)`)
const { chain } = useParams()
return above768 ? (
@@ -506,7 +506,7 @@ const TokenHeader = ({
export default function SingleToken() {
const theme = useTheme()
const navigate = useNavigate()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const [state, dispatch] = useChartStatesReducer()
const [showShare, setShowShare] = useState(false)
const above768 = useMedia(`(min-width:${MEDIA_WIDTHS.upToSmall}px)`)
diff --git a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx
index d63429edc5..a73a638efa 100644
--- a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx
+++ b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx
@@ -22,7 +22,7 @@ import Row, { RowBetween, RowFit } from 'components/Row'
import { APP_PATHS, ICON_ID } from 'constants/index'
import { NETWORKS_INFO } from 'constants/networks'
import { useActiveWeb3React } from 'hooks'
-import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
+import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel'
import { useOnClickOutside } from 'hooks/useOnClickOutside'
import useTheme from 'hooks/useTheme'
import { MEDIA_WIDTHS } from 'theme'
@@ -355,7 +355,7 @@ const tokenTypeList: {
const TokenListDraggableTabs = ({ tab, setTab }: { tab: KyberAIListType; setTab: (type: KyberAIListType) => void }) => {
const theme = useTheme()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const [showScrollRightButton, setShowScrollRightButton] = useState(false)
const [scrollLeftValue, setScrollLeftValue] = useState(0)
const wrapperRef = useRef(null)
@@ -478,7 +478,7 @@ const TokenRow = ({
}) => {
const navigate = useNavigate()
const location = useLocation()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const { account } = useActiveWeb3React()
const theme = useTheme()
const [showMenu, setShowMenu] = useState(false)
@@ -755,7 +755,7 @@ const LoadingRowSkeleton = ({ hasExtraCol }: { hasExtraCol?: boolean }) => {
}
export default function TokenAnalysisList() {
const theme = useTheme()
- const { mixpanelHandler } = useMixpanel()
+ const mixpanelHandler = useMixpanelKyberAI()
const [showShare, setShowShare] = useState(false)
const [isScrolling, setIsScrolling] = useState(false)
const [listType, setListType] = useState(KyberAIListType.BULLISH)
diff --git a/src/state/user/actions.ts b/src/state/user/actions.ts
index 23186d7acd..a4b07c0881 100644
--- a/src/state/user/actions.ts
+++ b/src/state/user/actions.ts
@@ -28,9 +28,6 @@ export const updateUserLocale = createAction<{ userLocale: SupportedLocale }>('u
export const updateUserSlippageTolerance = createAction<{ userSlippageTolerance: number }>(
'user/updateUserSlippageTolerance',
)
-export const updateUserSlippageToleranceForLineaTestnet = createAction<{ userSlippageTolerance: number }>(
- 'user/updateUserSlippageToleranceForLineaTestnet',
-)
export const updateUserDeadline = createAction<{ userDeadline: number }>('user/updateUserDeadline')
export const addSerializedToken = createAction<{ serializedToken: SerializedToken }>('user/addSerializedToken')
diff --git a/src/state/user/hooks.tsx b/src/state/user/hooks.tsx
index 6e3d3e1abd..8ce90dc275 100644
--- a/src/state/user/hooks.tsx
+++ b/src/state/user/hooks.tsx
@@ -4,7 +4,7 @@ import { useDispatch, useSelector } from 'react-redux'
import { useGetParticipantInfoQuery } from 'services/kyberAISubscription'
import { SUGGESTED_BASES } from 'constants/bases'
-import { DEFAULT_SLIPPAGE_TESTNET, TERM_FILES_PATH } from 'constants/index'
+import { TERM_FILES_PATH } from 'constants/index'
import { SupportedLocale } from 'constants/locales'
import { PINNED_PAIRS } from 'constants/tokens'
import { useActiveWeb3React } from 'hooks'
@@ -49,7 +49,6 @@ import {
updateUserDegenMode,
updateUserLocale,
updateUserSlippageTolerance,
- updateUserSlippageToleranceForLineaTestnet,
} from 'state/user/actions'
import { CROSS_CHAIN_SETTING_DEFAULT, CrossChainSetting, VIEW_MODE } from 'state/user/reducer'
import { isAddress, isChristmasTime } from 'utils'
@@ -154,23 +153,15 @@ export function useDegenModeManager(): [boolean, () => void] {
export function useUserSlippageTolerance(): [number, (slippage: number) => void] {
const dispatch = useDispatch()
- const { chainId } = useActiveWeb3React()
- const isLineaTestnet = chainId === ChainId.LINEA_TESTNET
const userSlippageTolerance = useSelector(state => {
- return isLineaTestnet
- ? state.user.userSlippageToleranceForLineaTestnet || DEFAULT_SLIPPAGE_TESTNET
- : state.user.userSlippageTolerance
+ return state.user.userSlippageTolerance
})
const setUserSlippageTolerance = useCallback(
(userSlippageTolerance: number) => {
- if (isLineaTestnet) {
- dispatch(updateUserSlippageToleranceForLineaTestnet({ userSlippageTolerance }))
- } else {
- dispatch(updateUserSlippageTolerance({ userSlippageTolerance }))
- }
+ dispatch(updateUserSlippageTolerance({ userSlippageTolerance }))
},
- [dispatch, isLineaTestnet],
+ [dispatch],
)
return [userSlippageTolerance, setUserSlippageTolerance]
diff --git a/src/state/user/reducer.ts b/src/state/user/reducer.ts
index 5adcce2af2..bf865318e1 100644
--- a/src/state/user/reducer.ts
+++ b/src/state/user/reducer.ts
@@ -6,7 +6,6 @@ import {
DEFAULT_DEADLINE_FROM_NOW,
DEFAULT_SLIPPAGE,
DEFAULT_SLIPPAGE_STABLE_PAIR_SWAP,
- DEFAULT_SLIPPAGE_TESTNET,
INITIAL_ALLOWED_SLIPPAGE,
MAX_NORMAL_SLIPPAGE_IN_BIPS,
} from 'constants/index'
@@ -43,7 +42,6 @@ import {
updateUserDegenMode,
updateUserLocale,
updateUserSlippageTolerance,
- updateUserSlippageToleranceForLineaTestnet,
} from './actions'
const currentTimestamp = () => new Date().getTime()
@@ -75,8 +73,6 @@ export interface UserState {
// user defined slippage tolerance in bips, used in all txns
userSlippageTolerance: number
- userSlippageToleranceForLineaTestnet: number
-
// deadline set by user in minutes, used in all txns
userDeadline: number
@@ -164,7 +160,6 @@ const initialState: UserState = {
userDegenModeAutoDisableTimestamp: 0,
userLocale: null,
userSlippageTolerance: INITIAL_ALLOWED_SLIPPAGE,
- userSlippageToleranceForLineaTestnet: DEFAULT_SLIPPAGE_TESTNET,
userDeadline: DEFAULT_DEADLINE_FROM_NOW,
tokens: {},
pairs: {},
@@ -256,10 +251,6 @@ export default createReducer(initialState, builder =>
state.userSlippageTolerance = action.payload.userSlippageTolerance
state.timestamp = currentTimestamp()
})
- .addCase(updateUserSlippageToleranceForLineaTestnet, (state, action) => {
- state.userSlippageToleranceForLineaTestnet = action.payload.userSlippageTolerance
- state.timestamp = currentTimestamp()
- })
.addCase(updateUserDeadline, (state, action) => {
state.userDeadline = action.payload.userDeadline
state.timestamp = currentTimestamp()
diff --git a/src/utils/aggregationRouting.ts b/src/utils/aggregationRouting.ts
index 9a4d87e7e8..36e9695aac 100644
--- a/src/utils/aggregationRouting.ts
+++ b/src/utils/aggregationRouting.ts
@@ -196,18 +196,12 @@ export function getTradeComposition(
})
if (index === 0) {
- const token = tokens[hop.tokenIn] || defaultToken
- path.push(
- allTokens?.[isAddressString(chainId, token.address)] ||
- new Token(chainId, token.address, token.decimals, token.symbol, token.name),
- )
+ const token = getTokenFromAddress(hop.tokenIn)
+ path.push(token)
}
- const token = allTokens?.[isAddressString(chainId, hop.tokenOut)] || tokens[hop.tokenOut] || defaultToken
- path.push(
- allTokens?.[isAddressString(chainId, token.address)] ||
- new Token(chainId, token.address, token.decimals, token.symbol, token.name),
- )
+ const token = getTokenFromAddress(hop.tokenOut)
+ path.push(token)
})
routes.push({
slug: path
diff --git a/src/utils/dmm.ts b/src/utils/dmm.ts
index 2baa3751d6..5e00914532 100644
--- a/src/utils/dmm.ts
+++ b/src/utils/dmm.ts
@@ -2,7 +2,6 @@ import { getAddress } from '@ethersproject/address'
import { BigNumber } from '@ethersproject/bignumber'
import { Pair } from '@kyberswap/ks-sdk-classic'
import { ChainId, Currency, CurrencyAmount, Fraction, Price, Token, TokenAmount } from '@kyberswap/ks-sdk-core'
-import { t } from '@lingui/macro'
import JSBI from 'jsbi'
import { useMemo } from 'react'
@@ -522,41 +521,3 @@ export function useRewardTokensFullInfo(): Token[] {
[chainId, nativeName, JSON.stringify(rewardTokens)],
)
}
-
-export function errorFriendly(text: string): string {
- const error = text?.toLowerCase?.() || ''
-
- if (!error || error.includes('router: expired')) {
- return 'An error occurred. Refresh the page and try again '
- }
-
- if (
- error.includes('mintotalamountout') ||
- error.includes('err_limit_out') ||
- error.includes('return amount is not enough') ||
- error.includes('code=call_exception') ||
- error.includes('none of the calls threw an error')
- ) {
- return t`An error occurred. Try refreshing the price rate or increase max slippage`
- }
- if (error.includes('header not found') || error.includes('swap failed')) {
- return t`An error occurred. Refresh the page and try again. If the issue still persists, it might be an issue with your RPC node settings in Metamask.`
- }
- if (error.includes('user rejected transaction') || error.includes('user denied transaction')) {
- return t`User rejected transaction.`
- }
-
- // classic/elastic remove liquidity error
- if (error.includes('insufficient')) {
- return t`An error occurred. Please try increasing max slippage`
- }
-
- if (error.includes('permit')) {
- return t`An error occurred. Invalid Permit Signature`
- }
- if (error.includes('burn amount exceeds balance')) {
- return t`Insufficient fee rewards amount, try to remove your liquidity without claiming fees for now and you can try to claim it later`
- }
-
- return t`An error occurred`
-}
diff --git a/src/utils/errorMessage.ts b/src/utils/errorMessage.ts
index 84e197007f..99246bcdd1 100644
--- a/src/utils/errorMessage.ts
+++ b/src/utils/errorMessage.ts
@@ -1,18 +1,66 @@
import { t } from '@lingui/macro'
+import { didUserReject } from 'constants/connectors/utils'
+
function capitalizeFirstLetter(string: string) {
return string.charAt(0).toUpperCase() + string.slice(1)
}
-// to be add more patterns ...
-const pattern1 = /{"originalError":.+"message":"execution reverted: ([^"]+)"/
-export function formatWalletErrorMessage(error: Error): string {
- const message = error.message
- if (message.length < 100) return message
+function parseKnownPattern(text: string): string | undefined {
+ const error = text?.toLowerCase?.() || ''
+ console.info('parseError:', { text, error })
+ if (!error || error.includes('router: expired')) return 'An error occurred. Refresh the page and try again '
+
+ if (
+ error.includes('mintotalamountout') ||
+ error.includes('err_limit_out') ||
+ error.includes('return amount is not enough') ||
+ error.includes('code=call_exception') ||
+ error.includes('none of the calls threw an error')
+ )
+ return t`An error occurred. Try refreshing the price rate or increase max slippage`
+
+ if (error.includes('header not found') || error.includes('swap failed'))
+ return t`An error occurred. Refresh the page and try again. If the issue still persists, it might be an issue with your RPC node settings in Metamask.`
+
+ if (didUserReject(error)) return t`User rejected the transaction.`
+
+ // classic/elastic remove liquidity error
+ if (error.includes('insufficient')) return t`An error occurred. Please try increasing max slippage`
+
+ if (error.includes('permit')) return t`An error occurred. Invalid Permit Signature`
+
+ if (error.includes('burn amount exceeds balance'))
+ return t`Insufficient fee rewards amount, try to remove your liquidity without claiming fees for now and you can try to claim it later`
- // extract & format long messages
- const pattern1Result = pattern1.exec(message)
- if (pattern1Result) return capitalizeFirstLetter(pattern1Result[1])
+ if (error === '[object Object]') return t`Something went wrong. Please try again`
+
+ return undefined
+}
+
+const patterns: { pattern: RegExp; getMessage: (match: RegExpExecArray) => string }[] = [
+ {
+ pattern: /{"originalError":.+"message":"execution reverted: ([^"]+)"/,
+ getMessage: match => match[1],
+ },
+ { pattern: /^([\w ]*\w+) \(.+?\)$/, getMessage: match => match[1] },
+]
+function parseKnownRegexPattern(text: string): string | undefined {
+ const pattern = patterns.find(pattern => pattern.pattern.exec(text))
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ if (pattern) return capitalizeFirstLetter(pattern.getMessage(pattern.pattern.exec(text)!))
+ return undefined
+}
+
+export function friendlyError(error: Error | string): string {
+ const message = typeof error === 'string' ? error : error.message
+
+ const knownPattern = parseKnownPattern(message)
+ if (knownPattern) return knownPattern
+
+ if (message.length < 100) return message
+ const knownRegexPattern = parseKnownRegexPattern(message)
+ if (knownRegexPattern) return knownRegexPattern
- return t`Unknown error. Please try again.`
+ return t`An error occurred`
}
diff --git a/src/utils/index.ts b/src/utils/index.ts
index 478da2b351..712f6c979b 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -57,6 +57,7 @@ export function getEtherscanLink(
return `${prefix}/tx/${data}`
}
case 'token': {
+ if (chainId === ChainId.ZKSYNC) return `${prefix}/address/${data}`
return `${prefix}/token/${data}`
}
case 'block': {
diff --git a/src/utils/priceImpact.ts b/src/utils/priceImpact.ts
index 530464eec9..985f5fd4dc 100644
--- a/src/utils/priceImpact.ts
+++ b/src/utils/priceImpact.ts
@@ -1,19 +1,6 @@
-import { ChainId } from '@kyberswap/ks-sdk-core'
-
-import { CHAINS_BYPASS_PRICE_IMPACT } from 'constants/networks'
import { checkPriceImpact } from 'utils/prices'
-export const checkShouldDisableByPriceImpact = (
- chainId: ChainId,
- isDegenMode: boolean,
- priceImpact: number | undefined,
-) => {
+export const checkShouldDisableByPriceImpact = (isDegenMode: boolean, priceImpact: number | undefined) => {
const priceImpactResult = checkPriceImpact(priceImpact)
- return checkAllowBypassPriceImpactRestriction(chainId)
- ? false
- : !isDegenMode && (priceImpactResult.isVeryHigh || priceImpactResult.isInvalid)
-}
-
-export const checkAllowBypassPriceImpactRestriction = (chainId: ChainId) => {
- return CHAINS_BYPASS_PRICE_IMPACT.includes(chainId)
+ return !isDegenMode && (priceImpactResult.isVeryHigh || priceImpactResult.isInvalid)
}
diff --git a/src/utils/sentry.ts b/src/utils/sentry.ts
index 2b30c34c60..8d9e73c78e 100644
--- a/src/utils/sentry.ts
+++ b/src/utils/sentry.ts
@@ -2,6 +2,10 @@ import { TransactionRequest } from '@ethersproject/abstract-provider'
import { captureException } from '@sentry/react'
import { Deferrable } from 'ethers/lib/utils'
+import { didUserReject } from 'constants/connectors/utils'
+
+import { friendlyError } from './errorMessage'
+
export enum ErrorName {
SwappError = 'SwapError',
RemoveElasticLiquidityError = 'RemoveElasticLiquidityError',
@@ -9,10 +13,12 @@ export enum ErrorName {
}
export function captureSwapError(error: TransactionError) {
- if (error.message.toLowerCase().includes('user canceled') || error.message.toLowerCase().includes('user reject')) {
- return
- }
- const e = new Error('Swap failed', { cause: error })
+ if (didUserReject(error)) return
+
+ const friendlyErrorResult = friendlyError(error)
+ if (friendlyErrorResult.includes('slippage')) return
+
+ const e = new Error(friendlyErrorResult, { cause: error })
e.name = ErrorName.SwappError
const tmp = JSON.stringify(error)
diff --git a/src/utils/slippage.ts b/src/utils/slippage.ts
index 8a6df00584..f4db43dec5 100644
--- a/src/utils/slippage.ts
+++ b/src/utils/slippage.ts
@@ -1,6 +1,4 @@
-import { ChainId } from '@kyberswap/ks-sdk-core'
-
-import { DEFAULT_SLIPPAGE, DEFAULT_SLIPPAGE_STABLE_PAIR_SWAP, DEFAULT_SLIPPAGE_TESTNET } from 'constants/index'
+import { DEFAULT_SLIPPAGE, DEFAULT_SLIPPAGE_STABLE_PAIR_SWAP } from 'constants/index'
export enum SLIPPAGE_STATUS {
NORMAL,
@@ -8,11 +6,7 @@ export enum SLIPPAGE_STATUS {
HIGH,
}
-export const getDefaultSlippage = (chainId: ChainId, isStablePairSwap: boolean): number => {
- if (chainId === ChainId.LINEA_TESTNET) {
- return DEFAULT_SLIPPAGE_TESTNET
- }
-
+export const getDefaultSlippage = (isStablePairSwap: boolean): number => {
return isStablePairSwap ? DEFAULT_SLIPPAGE_STABLE_PAIR_SWAP : DEFAULT_SLIPPAGE
}
diff --git a/yarn.lock b/yarn.lock
index 078f7e665b..ab6ee27380 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2068,10 +2068,10 @@
tiny-warning "^1.0.3"
toformat "^2.0.0"
-"@kyberswap/ks-sdk-core@1.0.8", "@kyberswap/ks-sdk-core@^1.0.5":
- version "1.0.8"
- resolved "https://registry.yarnpkg.com/@kyberswap/ks-sdk-core/-/ks-sdk-core-1.0.8.tgz#11dbcbc7fd2d1243e221c5e7436be2b7735ee108"
- integrity sha512-mbOr9oLcEmtKWdyXKio4pUWRBX0qkFHOrNmSet81MsXMCgIz59hMFqlZ7KSNL8j8iOJOR79j7s8deOUtghQsKA==
+"@kyberswap/ks-sdk-core@1.0.9", "@kyberswap/ks-sdk-core@^1.0.5":
+ version "1.0.9"
+ resolved "https://registry.yarnpkg.com/@kyberswap/ks-sdk-core/-/ks-sdk-core-1.0.9.tgz#9cb4915a9703948e840e62f332daca1282fcf189"
+ integrity sha512-kl2o0sw3Q+rR6KHxQbe57Gl2ajWv9IGaboOaRSpxCKsmA27hRmVaaiMmbbWfJNh8h6UZB9WohEoG/U48kD7o4Q==
dependencies:
"@ethersproject/address" "^5.0.2"
"@solana/web3.js" "^1.66.2"