Skip to content

Commit 5e95b03

Browse files
authored
fix: check suggested slippage before applying (#2872)
* fix: check suggested slippage before applying * fix: close claim modal if change account
1 parent f1dfd67 commit 5e95b03

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

apps/kyberswap-interface/src/components/SwapForm/SwapModal/ConfirmSwapModalContent.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ export default function ConfirmSwapModalContent({
385385
<TransactionErrorContent
386386
onDismiss={onDismiss}
387387
confirmAction={() => {
388-
if (retry < 1) {
388+
if (retry < 1 && slippage !== dynamicSuggestedSlippage) {
389389
setRetry(prev => prev + 1)
390390
setRawSlippage(dynamicSuggestedSlippage)
391391
} else {
@@ -394,16 +394,19 @@ export default function ConfirmSwapModalContent({
394394
onDismiss()
395395
}
396396
}}
397-
confirmText={retry < 1 ? t`Use Suggested Slippage` : t`Set Custom Slippage`}
397+
confirmText={
398+
retry < 1 && slippage !== dynamicSuggestedSlippage ? t`Use Suggested Slippage` : t`Set Custom Slippage`
399+
}
398400
message={
399-
retry < 1
401+
retry < 1 && slippage !== dynamicSuggestedSlippage
400402
? errorWhileBuildRoute
401403
: t`This route may currently be too volatile to execute. Try to custom your own slippage to continue.`
402404
}
403405
confirmBtnStyle={{ flex: 2 }}
404406
dismissBtnStyle={{ flex: 1 }}
405407
suggestionMessage={
406-
retry < 1 && (
408+
retry < 1 &&
409+
slippage !== dynamicSuggestedSlippage && (
407410
<Text marginTop="8px" fontSize={16} color={theme.text}>
408411
<Trans>New Suggested Slippage:</Trans> {(dynamicSuggestedSlippage * 100) / 10_000}%{' '}
409412
<InfoHelper

apps/kyberswap-interface/src/pages/Earns/hooks/useCollectFees.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useActiveWeb3React, useWeb3React } from 'hooks'
66
import ClaimModal, { ClaimInfo, ClaimType } from 'pages/Earns/components/ClaimModal'
77
import { EARN_DEXES, Exchange } from 'pages/Earns/constants'
88
import { CoreProtocol } from 'pages/Earns/constants/coreProtocol'
9+
import useAccountChanged from 'pages/Earns/hooks/useAccountChanged'
910
import useCompounding from 'pages/Earns/hooks/useCompounding'
1011
import { ParsedPosition } from 'pages/Earns/types'
1112
import { getNftManagerContract, submitTransaction } from 'pages/Earns/utils'
@@ -179,6 +180,8 @@ const useCollectFees = ({ refetchAfterCollect }: { refetchAfterCollect: () => vo
179180
}
180181
}, [allTransactions, refetchAfterCollect, txHash])
181182

183+
useAccountChanged(onCloseClaim)
184+
182185
const claimModal =
183186
openClaimModal && claimInfo ? (
184187
<>

apps/kyberswap-interface/src/pages/Earns/hooks/useKemRewards.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import useFilter from 'pages/Earns/UserPositions/useFilter'
1111
import ClaimAllModal from 'pages/Earns/components/ClaimAllModal'
1212
import ClaimModal, { ClaimInfo, ClaimType } from 'pages/Earns/components/ClaimModal'
1313
import { EARN_CHAINS, EarnChain } from 'pages/Earns/constants'
14+
import useAccountChanged from 'pages/Earns/hooks/useAccountChanged'
1415
import useCompounding from 'pages/Earns/hooks/useCompounding'
1516
import { ParsedPosition, RewardInfo, TokenInfo } from 'pages/Earns/types'
1617
import { getNftManagerContractAddress, submitTransaction } from 'pages/Earns/utils'
@@ -334,6 +335,11 @@ const useKemRewards = (refetchAfterCollect?: () => void) => {
334335
if (!rewardInfo?.chains.length) setOpenClaimAllModal(false)
335336
}, [rewardInfo?.chains.length])
336337

338+
useAccountChanged(() => {
339+
onCloseClaim()
340+
setOpenClaimAllModal(false)
341+
})
342+
337343
const claimModal =
338344
openClaimModal && claimInfo ? (
339345
<>

0 commit comments

Comments
 (0)