Skip to content

Commit

Permalink
Merge branch 'main' into e2e-test-chains
Browse files Browse the repository at this point in the history
  • Loading branch information
ltthienn authored Aug 16, 2023
2 parents 04acfe0 + 54d2ed6 commit c95ec7f
Show file tree
Hide file tree
Showing 41 changed files with 195 additions and 319 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Binary file removed src/assets/networks/avax-network.png
Binary file not shown.
Binary file removed src/assets/networks/bsc-network.png
Binary file not shown.
Binary file removed src/assets/networks/bttc.png
Binary file not shown.
Binary file removed src/assets/networks/ethw.png
Binary file not shown.
Binary file removed src/assets/networks/polygon-network.png
Binary file not shown.
Binary file removed src/assets/networks/zksync-network.png
Binary file not shown.
12 changes: 0 additions & 12 deletions src/assets/svg/eth_pow.svg

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/ClassicElasticTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => (
<Text
Expand Down
13 changes: 0 additions & 13 deletions src/components/Header/web3/NetworkModal/Networks.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChainId, getChainType } from '@kyberswap/ks-sdk-core'
import { Trans } from '@lingui/macro'
import { darken, rgba } from 'polished'
import { stringify } from 'querystring'
import React from 'react'
Expand All @@ -18,13 +17,6 @@ import useTheme from 'hooks/useTheme'
import { useChangeNetwork } from 'hooks/web3/useChangeNetwork'
import { useIsDarkMode } from 'state/user/hooks'

const NewLabel = styled.span`
font-size: 12px;
color: ${({ theme }) => theme.red};
margin-left: 2px;
margin-top: -10px;
`

const ListItem = styled.div<{ selected?: boolean }>`
width: 100%;
display: flex;
Expand Down Expand Up @@ -197,11 +189,6 @@ const Networks = ({
{name}
</Text>
</Flex>
{key === ChainId.LINEA && (
<NewLabel>
<Trans>New</Trans>
</NewLabel>
)}
{selected && !walletKey && <CircleGreen />}
{walletKey && (
<WalletWrapper>
Expand Down
6 changes: 1 addition & 5 deletions src/components/SwapForm/PriceImpactNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand All @@ -33,11 +31,9 @@ type Props = {
}

const PriceImpactNote: FC<Props> = ({ isDegenMode, priceImpact }) => {
const { chainId } = useActiveWeb3React()
const priceImpactResult = checkPriceImpact(priceImpact)
const shouldHide = checkAllowBypassPriceImpactRestriction(chainId)

if (typeof priceImpact !== 'number' || shouldHide) {
if (typeof priceImpact !== 'number') {
return null
}

Expand Down
6 changes: 2 additions & 4 deletions src/components/SwapForm/SlippageSetting.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -50,7 +49,6 @@ export const SwapButtonWithPriceImpact = ({
showTooltipPriceImpact?: boolean
}) => {
const theme = useTheme()
const { chainId } = useActiveWeb3React()
const [isDegenMode] = useDegenModeManager()
const priceImpactResult = checkPriceImpact(priceImpact)

Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/SwapForm/SwapModal/ConfirmSwapModalContent.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
40 changes: 19 additions & 21 deletions src/components/SwapForm/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -216,26 +216,24 @@ const SwapForm: React.FC<SwapFormProps> = props => {
</Flex>

<Flex sx={{ gap: '12px' }}>
{chainId === ChainId.LINEA_TESTNET ? null : (
<PriceAlertButton
onClick={() =>
navigate(
`${APP_PATHS.PROFILE_MANAGE}${PROFILE_MANAGE_ROUTES.CREATE_ALERT}?${stringify({
amount: typedValue || undefined,
inputCurrency: currencyId(currencyIn, chainId),
outputCurrency: currencyId(currencyOut, chainId),
})}`,
)
}
>
<Clock size={14} color={theme.subText} />
{upToExtraSmall ? null : (
<Text color={theme.subText} style={{ whiteSpace: 'nowrap' }}>
<Trans>Price Alert</Trans>
</Text>
)}
</PriceAlertButton>
)}
<PriceAlertButton
onClick={() =>
navigate(
`${APP_PATHS.PROFILE_MANAGE}${PROFILE_MANAGE_ROUTES.CREATE_ALERT}?${stringify({
amount: typedValue || undefined,
inputCurrency: currencyId(currencyIn, chainId),
outputCurrency: currencyId(currencyOut, chainId),
})}`,
)
}
>
<Clock size={14} color={theme.subText} />
{upToExtraSmall ? null : (
<Text color={theme.subText} style={{ whiteSpace: 'nowrap' }}>
<Trans>Price Alert</Trans>
</Text>
)}
</PriceAlertButton>
<ReverseTokenSelectionButton onClick={() => currencyIn && handleChangeCurrencyOut(currencyIn)} />
</Flex>
</AutoRow>
Expand Down
9 changes: 2 additions & 7 deletions src/constants/bases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const WETH_ONLY: ChainTokenList = {
[ChainId.OPTIMISM]: [WETH[ChainId.OPTIMISM]],
[ChainId.ZKSYNC]: [WETH[ChainId.ZKSYNC]],
[ChainId.SOLANA]: [WETH[ChainId.SOLANA]],
[ChainId.LINEA_TESTNET]: [WETH[ChainId.LINEA_TESTNET]],
[ChainId.LINEA]: [WETH[ChainId.LINEA]],
[ChainId.ZKEVM]: [WETH[ChainId.ZKEVM]],
[ChainId.SOLANA_DEVNET]: [WETH[ChainId.SOLANA_DEVNET]],
}

Expand Down Expand Up @@ -178,12 +178,7 @@ export const SUGGESTED_BASES: ChainTokenList = {
new Token(ChainId.ZKSYNC, '0x503234f203fc7eb888eec8513210612a43cf6115', 18, 'LUSD', 'LUSD'),
new Token(ChainId.ZKSYNC, '0xbbeb516fb02a01611cbbe0453fe3c580d7281011', 8, 'wBTC', 'wBTC'),
],
[ChainId.LINEA_TESTNET]: [
...WETH_ONLY[ChainId.LINEA_TESTNET],
USDC[ChainId.LINEA_TESTNET],
USDT[ChainId.LINEA_TESTNET],
DAI[ChainId.LINEA_TESTNET],
],
[ChainId.ZKEVM]: [...WETH_ONLY[ChainId.ZKEVM], USDC[ChainId.ZKEVM], USDT[ChainId.ZKEVM], DAI[ChainId.ZKEVM]],
[ChainId.LINEA]: [
...WETH_ONLY[ChainId.LINEA],
new Token(ChainId.LINEA, '0x7d43aabc515c356145049227cee54b608342c0ad', 18, 'BUSD', 'BUSD'),
Expand Down
3 changes: 1 addition & 2 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '.' '..' '...' '.' '..' '...'

Expand Down Expand Up @@ -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'

Expand Down
26 changes: 12 additions & 14 deletions src/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
fantom,
görli,
linea,
lineaTestnet,
matic,
mumbai,
oasis,
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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<
Expand Down Expand Up @@ -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 = [
Expand All @@ -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
Expand Down Expand Up @@ -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]
5 changes: 2 additions & 3 deletions src/constants/networks/avax-testnet.ts
Original file line number Diff line number Diff line change
@@ -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 = ''
Expand All @@ -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,
Expand All @@ -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,
},
Expand Down
5 changes: 2 additions & 3 deletions src/constants/networks/avax.ts
Original file line number Diff line number Diff line change
@@ -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 = ''
Expand All @@ -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,
Expand All @@ -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,
},
Expand Down
Loading

0 comments on commit c95ec7f

Please sign in to comment.