Skip to content

Commit d02f65c

Browse files
authored
feat: add bsc mev protection (#2860)
* feat: add bsc mev protection * fix: lint
1 parent 54778fb commit d02f65c

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

apps/kyberswap-interface/src/components/SwapForm/AddMEVProtectionModal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ const Wrapper = styled.div`
3737
}
3838
`
3939

40-
const KYBER_SWAP_RPC: { [key: number]: string } = {
40+
export const KYBER_SWAP_RPC: Partial<Record<ChainId, string>> = {
4141
[ChainId.MAINNET]: 'https://ethereum-mev-protection.kyberengineering.io/',
42+
[ChainId.BSCMAINNET]: 'https://bsc-mev-protection.kyberengineering.io/',
4243
// [ChainId.BASE]: 'https://base-mev-protection.kyberengineering.io/',
4344
}
4445

@@ -64,7 +65,7 @@ export default function AddMEVProtectionModal({ isOpen, onClose }: { isOpen: boo
6465
mixpanelHandler(MIXPANEL_TYPE.MEV_ADD_CLICK_MODAL, { type: name })
6566
addNewNetwork(
6667
chainId,
67-
KYBER_SWAP_RPC[chainId],
68+
KYBER_SWAP_RPC[chainId] as string,
6869
{
6970
name,
7071
title: t`Failed to switch to ${name} RPC Endpoint`,

apps/kyberswap-interface/src/components/SwapForm/SlippageSettingGroup.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import styled from 'styled-components'
1010
import { ReactComponent as DropdownSVG } from 'assets/svg/down.svg'
1111
import { Shield } from 'components/Icons'
1212
import InfoHelper from 'components/InfoHelper'
13+
import AddMEVProtectionModal, { KYBER_SWAP_RPC } from 'components/SwapForm/AddMEVProtectionModal'
1314
import SlippageSetting from 'components/SwapForm/SlippageSetting'
1415
import { MouseoverTooltip, TextDashed } from 'components/Tooltip'
1516
import { APP_PATHS } from 'constants/index'
@@ -19,8 +20,6 @@ import useTheme from 'hooks/useTheme'
1920
import { usePaymentToken, useSlippageSettingByPage } from 'state/user/hooks'
2021
import { MEDIA_WIDTHS } from 'theme'
2122

22-
import AddMEVProtectionModal from './AddMEVProtectionModal'
23-
2423
export const PriceAlertButton = styled.div`
2524
background: ${({ theme }) => rgba(theme.subText, 0.2)};
2625
border-radius: 24px;
@@ -61,7 +60,7 @@ export default function SlippageSettingGroup({
6160
const { isSlippageControlPinned } = useSlippageSettingByPage()
6261
const isPartnerSwap = window.location.pathname.startsWith(APP_PATHS.PARTNER_SWAP)
6362
let rightButton =
64-
[ChainId.MAINNET].includes(chainId) && active && !isPartnerSwap && !isMobile && !isTablet ? (
63+
KYBER_SWAP_RPC[chainId] && active && !isPartnerSwap && !isMobile && !isTablet ? (
6564
<PriceAlertButton onClick={addMevProtectionHandler}>
6665
<Shield size={14} color={theme.subText} />
6766
<Text color={theme.subText} style={{ whiteSpace: 'nowrap' }}>

apps/kyberswap-interface/src/components/SwapForm/SwapModal/SwapDetails/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChainId, Currency, CurrencyAmount } from '@kyberswap/ks-sdk-core'
1+
import { Currency, CurrencyAmount } from '@kyberswap/ks-sdk-core'
22
import { Trans, t } from '@lingui/macro'
33
import { rgba } from 'polished'
44
import { useCallback, useState } from 'react'
@@ -14,7 +14,7 @@ import Divider from 'components/Divider'
1414
import { Shield } from 'components/Icons'
1515
import InfoHelper from 'components/InfoHelper'
1616
import { RowBetween, RowFixed } from 'components/Row'
17-
import AddMEVProtectionModal from 'components/SwapForm/AddMEVProtectionModal'
17+
import AddMEVProtectionModal, { KYBER_SWAP_RPC } from 'components/SwapForm/AddMEVProtectionModal'
1818
import { PriceAlertButton } from 'components/SwapForm/SlippageSettingGroup'
1919
import { useSwapFormContext } from 'components/SwapForm/SwapFormContext'
2020
import ValueWithLoadingSkeleton from 'components/SwapForm/SwapModal/SwapDetails/ValueWithLoadingSkeleton'
@@ -116,7 +116,7 @@ export default function SwapDetails({ isLoading, gasUsd, minimumAmountOut, price
116116
const upToXXSmall = useMedia(`(max-width: ${MEDIA_WIDTHS.upToXXSmall}px)`)
117117
const isPartnerSwap = window.location.pathname.startsWith(APP_PATHS.PARTNER_SWAP)
118118
const addMevButton =
119-
chainId === ChainId.MAINNET &&
119+
KYBER_SWAP_RPC[chainId] &&
120120
active &&
121121
!isPartnerSwap &&
122122
slippageStatus === SLIPPAGE_STATUS.HIGH &&

0 commit comments

Comments
 (0)