Skip to content

Commit

Permalink
fix: slp message
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv committed Jun 10, 2024
1 parent dfc55d1 commit c926961
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
12 changes: 11 additions & 1 deletion src/components/SlippageWarningNote/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,23 @@ const SlippageWarningNote: FC<Props> = ({ className, rawSlippage, isStablePairSw
return null
}

let msg = 'is high. Your transaction may be front-run.'
let msg = 'setting might be high. You might want to adjust it to avoid potential front-running.'
if (slippageStatus === SLIPPAGE_STATUS.LOW) {
msg = 'is low. Your transaction may fail.'
}

if (isStablePairSwap)
msg =
'setting might be high compared to typical stable pair trades. Consider adjusting it to reduce the risk of front-running.'
if (isCorrelatedPair)
msg =
'setting might be high compared with other similar trades. You might want to adjust it to avoid potential front-running.'

const shortText = (
<div>
<Trans>
<TextUnderlineTransparent>Your </TextUnderlineTransparent>

<TextUnderlineColor
style={{ minWidth: 'max-content' }}
as="a"
Expand Down
12 changes: 11 additions & 1 deletion src/components/SwapForm/SlippageSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,17 @@ const SlippageSetting = ({ isStablePairSwap, isCorrelatedPair, rightComponent, t
borderBottom: isWarningSlippage ? `1px dashed ${theme.warning}` : 'none',
}}
>
<MouseoverTooltip text={isWarningSlippage ? t`Slippage is high. Your transaction may be front-run.` : ''}>
<MouseoverTooltip
text={
isWarningSlippage
? isStablePairSwap
? t`Your slippage setting might be high compared to typical stable pair trades. Consider adjusting it to reduce the risk of front-running.`
: isCorrelatedPair
? t`Your slippage setting might be high compared with other similar trades. You might want to adjust it to avoid potential front-running.`
: t`Your slippage setting might be high. You might want to adjust it to avoid potential front-running.`
: ''
}
>
{formatSlippage(rawSlippage)}
</MouseoverTooltip>
</Text>
Expand Down
10 changes: 7 additions & 3 deletions src/components/swapv2/SwapSettingsPanel/SlippageSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MouseoverTooltip, TextDashed } from 'components/Tooltip'
import PinButton from 'components/swapv2/SwapSettingsPanel/PinButton'
import { DEFAULT_SLIPPAGE, DEFAULT_SLIPPAGE_STABLE_PAIR_SWAP } from 'constants/index'
import useTheme from 'hooks/useTheme'
import { useCheckStablePairSwap } from 'state/swap/hooks'
import { useCheckCorrelatedPair, useCheckStablePairSwap } from 'state/swap/hooks'
import { useSlippageSettingByPage } from 'state/user/hooks'
import { ExternalLink } from 'theme'
import { SLIPPAGE_STATUS, checkRangeSlippage } from 'utils/slippage'
Expand All @@ -35,7 +35,7 @@ const SlippageSetting: React.FC<Props> = ({ shouldShowPinButton = true }) => {
const { rawSlippage, setRawSlippage, isSlippageControlPinned, togglePinSlippage } = useSlippageSettingByPage()

const isStablePairSwap = useCheckStablePairSwap()
const isCorrelatedPair = useCheckStablePairSwap()
const isCorrelatedPair = useCheckCorrelatedPair()
const slippageStatus = checkRangeSlippage(rawSlippage, isStablePairSwap, isCorrelatedPair)
const isWarning = slippageStatus !== SLIPPAGE_STATUS.NORMAL
const theme = useTheme()
Expand Down Expand Up @@ -84,7 +84,11 @@ const SlippageSetting: React.FC<Props> = ({ shouldShowPinButton = true }) => {
{isWarning && (
<Message data-warning={true} data-error={false}>
{slippageStatus === SLIPPAGE_STATUS.HIGH
? t`Slippage is high. Your transaction may be front-run.`
? isStablePairSwap
? t`Your slippage setting might be high compared to typical stable pair trades. Consider adjusting it to reduce the risk of front-running.`
: isCorrelatedPair
? t`Your slippage setting might be high compared with other similar trades. You might want to adjust it to avoid potential front-running.`
: t`Your slippage setting might be high. You might want to adjust it to avoid potential front-running.`
: t`Slippage is low. Your transaction may fail.`}
</Message>
)}
Expand Down
1 change: 0 additions & 1 deletion src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export const SUPER_STABLE_COINS_ADDRESS: { [chainId in ChainId]: string[] } = {
],
[ChainId.LINEA]: [],
[ChainId.SCROLL]: [],
[ChainId.SCROLL]: [],
[ChainId.BLAST]: [],
[ChainId.MANTLE]: [],
[ChainId.XLAYER]: [],
Expand Down

0 comments on commit c926961

Please sign in to comment.