Skip to content

Commit

Permalink
feat: honeypot and fot detect (#2510)
Browse files Browse the repository at this point in the history
* feat: honeypot and fot detect

* Update index.tsx

Signed-off-by: Nguyen Van Viet <vietnv1304@gmail.com>

---------

Signed-off-by: Nguyen Van Viet <vietnv1304@gmail.com>
  • Loading branch information
viet-nv authored Jul 29, 2024
1 parent 5cffcbd commit 7d96a63
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ VITE_WALLETCONNECT_PROJECT_ID=b5b37945209ea323811f1032e84eaeb5

VITE_CAMPAIGN_URL=https://kyberswap-arbitrum-stip.kyberengineering.io/api
VITE_REFERRAL_URL=https://referral.kyberswap.com/api

VITE_TOKEN_API_URL=https://pre-token-api.kyberengineering.io/api
2 changes: 2 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ VITE_WALLETCONNECT_PROJECT_ID=b5b37945209ea323811f1032e84eaeb5

VITE_CAMPAIGN_URL=https://kyberswap-arbitrum-stip.kyberengineering.io/api
VITE_REFERRAL_URL=https://referral.kyberswap.com/api

VITE_TOKEN_API_URL=https://pre-token-api.kyberengineering.io/api
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ VITE_WALLETCONNECT_PROJECT_ID=b5b37945209ea323811f1032e84eaeb5

VITE_CAMPAIGN_URL=https://kyberswap-arbitrum-stip.kyberengineering.io/api
VITE_REFERRAL_URL=https://referral.kyberswap.com/api

VITE_TOKEN_API_URL=https://pre-token-api.kyberengineering.io/api
1 change: 1 addition & 0 deletions .env.stg
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ VITE_WALLETCONNECT_PROJECT_ID=b5b37945209ea323811f1032e84eaeb5
VITE_CAMPAIGN_URL=https://kyberswap-arbitrum-stip.kyberengineering.io/api
VITE_REFERRAL_URL=https://referral.kyberswap.com/api

VITE_TOKEN_API_URL=https://pre-token-api.kyberengineering.io/api
41 changes: 40 additions & 1 deletion src/components/SwapForm/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { ChainId, Currency, CurrencyAmount } from '@kyberswap/ks-sdk-core'
import { rgba } from 'polished'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { useSearchParams } from 'react-router-dom'
import { Box, Flex } from 'rebass'
import { Box, Flex, Text } from 'rebass'
import { parseGetRouteResponse } from 'services/route/utils'
import styled from 'styled-components'

import { ReactComponent as RoutingIcon } from 'assets/svg/routing-icon.svg'
import AddressInputPanel from 'components/AddressInputPanel'
import FeeControlGroup from 'components/FeeControlGroup'
import WarningIcon from 'components/Icons/WarningIcon'
import { NetworkSelector } from 'components/NetworkSelector'
import InputCurrencyPanel from 'components/SwapForm/InputCurrencyPanel'
import OutputCurrencyPanel from 'components/SwapForm/OutputCurrencyPanel'
Expand All @@ -21,7 +23,9 @@ import useGetRoute from 'components/SwapForm/hooks/useGetRoute'
import useParsedAmount from 'components/SwapForm/hooks/useParsedAmount'
import { TutorialIds } from 'components/Tutorial/TutorialSwap/constant'
import { Wrapper } from 'components/swapv2/styleds'
import { TOKEN_API_URL } from 'constants/env'
import { useActiveWeb3React } from 'hooks'
import useTheme from 'hooks/useTheme'
import useWrapCallback, { WrapType } from 'hooks/useWrapCallback'
import useUpdateSlippageInStableCoinSwap from 'pages/SwapV3/useUpdateSlippageInStableCoinSwap'
import { Field } from 'state/swap/actions'
Expand Down Expand Up @@ -153,6 +157,21 @@ const SwapForm: React.FC<SwapFormProps> = props => {
setRouteSummary(routeSummary)
}, [routeSummary, setRouteSummary])

const theme = useTheme()

const [honeypot, setHoneypot] = useState<{ isHoneypot: boolean; isFOT: boolean; tax: number } | null>(null)

useEffect(() => {
if (!currencyOut) return
fetch(
`${TOKEN_API_URL}/v1/public/tokens/honeypot-fot-info?address=${currencyOut.wrapped.address.toLowerCase()}&chainId=${chainId}`,
)
.then(res => res.json())
.then(res => {
setHoneypot(res.data)
})
}, [currencyOut, chainId])

return (
<SwapFormContextProvider
slippage={slippage}
Expand Down Expand Up @@ -224,6 +243,26 @@ const SwapForm: React.FC<SwapFormProps> = props => {
/>
)}

{honeypot?.isFOT || honeypot?.isHoneypot ? (
<Flex
sx={{
borderRadius: '1rem',
background: rgba(theme.warning, 0.3),
padding: '10px 12px',
gap: '8px',
}}
>
<WarningIcon color={theme.warning} size={20} />
<Text fontSize={14} flex={1}>
{honeypot.isHoneypot
? `Our simulation detects that ${currencyOut?.symbol} token can not be sold immediately or has an extremely high sell fee after being bought, please check further before buying!`
: `Our simulation detects that ${currencyOut?.symbol} has ${
honeypot.tax * 100
}% fee on transfer, please check further before buying.`}
</Text>
</Flex>
) : null}

<SwapActionButton
isGettingRoute={isGettingRoute}
parsedAmountFromTypedValue={parsedAmount}
Expand Down
1 change: 1 addition & 0 deletions src/constants/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const BUCKET_NAME = required('BUCKET_NAME')
export const WALLETCONNECT_PROJECT_ID = required('WALLETCONNECT_PROJECT_ID')
export const CAMPAIGN_URL = required('CAMPAIGN_URL')
export const REFERRAL_URL = required('REFERRAL_URL')
export const TOKEN_API_URL = required('TOKEN_API_URL')

type FirebaseConfig = {
apiKey: string
Expand Down

0 comments on commit 7d96a63

Please sign in to comment.