Skip to content

Commit 8097607

Browse files
committed
fix: do not suggest TWAP when cross-chain swap
1 parent dd05bb7 commit 8097607

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

apps/cowswap-frontend/src/locales/en-US.po

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ msgid "Signature is undefined!"
3232
msgstr "Signature is undefined!"
3333

3434
#: apps/cowswap-frontend/src/modules/orderProgressBar/pure/BenefitComponents.tsx
35-
msgid "I just received surplus on"
36-
msgstr "I just received surplus on"
35+
#~ msgid "I just received surplus on"
36+
#~ msgstr "I just received surplus on"
3737

3838
#: apps/cowswap-frontend/src/modules/twap/utils/deadlinePartsDisplay.ts
3939
msgid "years"
@@ -613,6 +613,10 @@ msgstr "If your order has not been filled by this date & time, it will expire. D
613613
msgid "Only proceed if you trust this provider."
614614
msgstr "Only proceed if you trust this provider."
615615

616+
#: apps/cowswap-frontend/src/modules/orderProgressBar/pure/BenefitComponents.tsx
617+
msgid "I received surplus on"
618+
msgstr "I received surplus on"
619+
616620
#: apps/cowswap-frontend/src/modules/application/containers/App/CowSpeechBubble.tsx
617621
msgid "View jobs"
618622
msgstr "View jobs"
@@ -2202,6 +2206,10 @@ msgstr "Failed to fetch manifest from {manifestUrl}. Please verify the URL and t
22022206
msgid "Order executes at"
22032207
msgstr "Order executes at"
22042208

2209+
#: apps/cowswap-frontend/src/modules/notifications/containers/NotificationSidebar/index.tsx
2210+
msgid "Trade alert settings"
2211+
msgstr "Trade alert settings"
2212+
22052213
#: apps/cowswap-frontend/src/modules/orderProgressBar/pure/steps/SolvingStep.tsx
22062214
msgid "There may be a network issue (such as a gas spike) that is delaying your order. You can wait for the issue to resolve{cancellationModal}"
22072215
msgstr "There may be a network issue (such as a gas spike) that is delaying your order. You can wait for the issue to resolve{cancellationModal}"
@@ -3738,6 +3746,10 @@ msgstr "Transaction expiration"
37383746
msgid "CowSwap no connection"
37393747
msgstr "CowSwap no connection"
37403748

3749+
#: apps/cowswap-frontend/src/modules/application/containers/App/CowSpeechBubble.tsx
3750+
msgid "View jobs (opens in a new tab)"
3751+
msgstr "View jobs (opens in a new tab)"
3752+
37413753
#: apps/cowswap-frontend/src/modules/account/containers/Transaction/ActivityDetails.tsx
37423754
#: apps/cowswap-frontend/src/modules/bridge/pure/BridgeActivitySummary/BridgeSummaryHeader.tsx
37433755
#: apps/cowswap-frontend/src/modules/ordersTable/containers/OrderRow/EstimatedExecutionPrice.tsx
@@ -6068,8 +6080,8 @@ msgid "Dark mode"
60686080
msgstr "Dark mode"
60696081

60706082
#: apps/cowswap-frontend/src/common/pure/ReceiveAmountInfo/index.tsx
6071-
#~ msgid "Bridge costs"
6072-
#~ msgstr "Bridge costs"
6083+
msgid "Bridge costs"
6084+
msgstr "Bridge costs"
60736085

60746086
#: apps/cowswap-frontend/src/modules/account/containers/Transaction/StatusDetails.tsx
60756087
msgid "View cancellation"
@@ -6285,10 +6297,3 @@ msgstr "Learn more"
62856297
#: apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/highFeeWarningHelpers.ts
62866298
msgid "Swap and bridge costs are at least {formattedFeePercentage}% of the swap amount"
62876299
msgstr "Swap and bridge costs are at least {formattedFeePercentage}% of the swap amount"
6288-
6289-
# Notifications / jobs aria labels
6290-
msgid "Trade alert settings"
6291-
msgstr "Trade alert settings"
6292-
6293-
msgid "View jobs (opens in a new tab)"
6294-
msgstr "View jobs (opens in a new tab)"

apps/cowswap-frontend/src/modules/swap/containers/Warnings/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from 'react'
1+
import React, { ReactNode } from 'react'
22

33
import { useWalletInfo } from '@cowprotocol/wallet'
44
import { TradeType } from '@cowprotocol/widget-lib'
55
import { Currency, CurrencyAmount } from '@uniswap/sdk-core'
66

77
import { useInjectedWidgetParams } from 'modules/injectedWidget'
8-
import { useTradePriceImpact, useTradeRouteContext } from 'modules/trade'
8+
import { useIsCurrentTradeBridging, useTradePriceImpact, useTradeRouteContext } from 'modules/trade'
99
import { BundleTxWrapBanner, HighFeeWarning, MetamaskTransactionWarning } from 'modules/tradeWidgetAddons'
1010
import { SellNativeWarningBanner } from 'modules/tradeWidgetAddons'
1111

@@ -17,19 +17,19 @@ interface WarningsProps {
1717
buyingFiatAmount: CurrencyAmount<Currency> | null
1818
}
1919

20-
// TODO: Add proper return type annotation
21-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
22-
export function Warnings({ buyingFiatAmount }: WarningsProps) {
20+
export function Warnings({ buyingFiatAmount }: WarningsProps): ReactNode {
2321
const { chainId } = useWalletInfo()
2422
const { inputCurrency, inputCurrencyAmount } = useSwapDerivedState()
2523
const formState = useSwapFormState()
2624
const tradeUrlParams = useTradeRouteContext()
25+
const isCurrentTradeBridging = useIsCurrentTradeBridging()
2726
const isNativeSellInHooksStore = formState === SwapFormState.SellNativeInHooks
2827

2928
const priceImpactParams = useTradePriceImpact()
3029
const widgetParams = useInjectedWidgetParams()
3130
const { enabledTradeTypes } = widgetParams
32-
const showTwapSuggestionBanner = !enabledTradeTypes || enabledTradeTypes.includes(TradeType.ADVANCED)
31+
const showTwapSuggestionBanner =
32+
(!enabledTradeTypes || enabledTradeTypes.includes(TradeType.ADVANCED)) && !isCurrentTradeBridging
3333

3434
return (
3535
<>

apps/cowswap-frontend/src/modules/swap/pure/TwapSuggestionBanner.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ReactNode } from 'react'
2+
13
import { getIsNativeToken } from '@cowprotocol/common-utils'
24
import { mapSupportedNetworks, OrderKind, SupportedChainId } from '@cowprotocol/cow-sdk'
35
import { InlineBanner, StatusColorVariant } from '@cowprotocol/ui'
@@ -36,16 +38,13 @@ const AMOUNT_LIMIT: Record<SupportedChainId, number> = {
3638
[SupportedChainId.MAINNET]: 50_000, // $50,000 for mainnet
3739
}
3840

39-
// TODO: Add proper return type annotation
40-
// TODO: Reduce function complexity by extracting logic
41-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
4241
export function TwapSuggestionBanner({
4342
priceImpact,
4443
buyingFiatAmount,
4544
tradeUrlParams,
4645
chainId,
4746
sellAmount,
48-
}: TwapSuggestionBannerProps) {
47+
}: TwapSuggestionBannerProps): ReactNode {
4948
if (!priceImpact || priceImpact.lessThan(0)) return null
5049

5150
const isSellNative = !!sellAmount?.currency && getIsNativeToken(sellAmount?.currency)

0 commit comments

Comments
 (0)