From 1aa73918dfc4300197e0cc90439929705a1fb219 Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Mon, 14 Oct 2024 16:26:49 +0100 Subject: [PATCH 1/9] feat: increase max deadline for swaps to 12h --- .../tradeWidgetAddons/containers/TransactionSettings/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx b/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx index eb3d25cfb9..f6bb3ea6c9 100644 --- a/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx +++ b/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx @@ -48,7 +48,7 @@ import useNativeCurrency from 'lib/hooks/useNativeCurrency' import * as styledEl from './styled' -const MAX_DEADLINE_MINUTES = 180 // 3h +const MAX_DEADLINE_MINUTES = 60 * 12 // 12h enum SlippageError { InvalidInput = 'InvalidInput', From aa8829c2d11100a7ea7d4e640a2f3674ccfd2d87 Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Mon, 14 Oct 2024 16:27:43 +0100 Subject: [PATCH 2/9] chore: linting --- .../containers/TransactionSettings/index.tsx | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx b/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx index f6bb3ea6c9..403c042989 100644 --- a/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx +++ b/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx @@ -149,15 +149,16 @@ export function TransactionSettings({ deadlineState }: TransactionSettingsProps) setDeadlineInput(value) setDeadlineError(false) - if (value.length === 0) { - orderExpirationTimeAnalytics('Default', DEFAULT_DEADLINE_FROM_NOW) - setDeadline(DEFAULT_DEADLINE_FROM_NOW) - } else { - try { - const parsed: number = Math.floor(Number.parseFloat(value) * 60) - if ( - !Number.isInteger(parsed) || // Check deadline is a number - parsed < minDeadline || // Check deadline is not too small + if (value.length === 0) { + orderExpirationTimeAnalytics('Default', DEFAULT_DEADLINE_FROM_NOW) + setDeadline(DEFAULT_DEADLINE_FROM_NOW) + } else { + try { + const parsed: number = Math.floor(Number.parseFloat(value) * 60) + if ( + !Number.isInteger(parsed) || // Check deadline is a number + parsed < + minDeadline || // Check deadline is not too small parsed > maxDeadline // Check deadline is not too big ) { setDeadlineError(DeadlineError.InvalidInput) @@ -279,7 +280,8 @@ export function TransactionSettings({ deadlineState }: TransactionSettingsProps) - CoW Swap has dynamically selected this slippage amount to account for current gas prices and trade + CoW Swap has dynamically selected this slippage amount to + account for current gas prices and trade size. Changes may result in slower execution. } From 2bce57a93819a0acb2934185f27320f66ac1fd71 Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Thu, 17 Oct 2024 11:08:54 +0100 Subject: [PATCH 3/9] chore: fix typo --- .../src/common/containers/InvalidLocalTimeWarning/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/cowswap-frontend/src/common/containers/InvalidLocalTimeWarning/index.tsx b/apps/cowswap-frontend/src/common/containers/InvalidLocalTimeWarning/index.tsx index 0a9b8e5401..ae41704018 100644 --- a/apps/cowswap-frontend/src/common/containers/InvalidLocalTimeWarning/index.tsx +++ b/apps/cowswap-frontend/src/common/containers/InvalidLocalTimeWarning/index.tsx @@ -16,8 +16,7 @@ export function InvalidLocalTimeWarning() { return ( - Local device time does is not accurate, CoW Swap most likely will not work correctly. Please adjust your device's - time. + Local device time is not accurate, CoW Swap most likely will not work correctly. Please adjust your device's time. ) } From ccbb223425ba16b247fe458686a7f94af5d475a7 Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Thu, 17 Oct 2024 11:44:34 +0100 Subject: [PATCH 4/9] feat: use only validFor on quote requests, remove validTo --- .../src/api/cowProtocol/api.ts | 30 +++++++------------ .../FeesUpdater/isRefetchQuoteRequired.ts | 4 +-- .../FeesUpdater/quoteUsingSameParameters.ts | 7 +++-- .../orders/UnfillableOrdersUpdater.ts | 12 ++------ .../src/legacy/utils/priceLegacy.ts | 26 +++++----------- .../src/utils/orderUtils/getQuoteValidFor.ts | 10 +++++++ 6 files changed, 37 insertions(+), 52 deletions(-) create mode 100644 apps/cowswap-frontend/src/utils/orderUtils/getQuoteValidFor.ts diff --git a/apps/cowswap-frontend/src/api/cowProtocol/api.ts b/apps/cowswap-frontend/src/api/cowProtocol/api.ts index 1eacdf5ea7..90ff5493cf 100644 --- a/apps/cowswap-frontend/src/api/cowProtocol/api.ts +++ b/apps/cowswap-frontend/src/api/cowProtocol/api.ts @@ -10,7 +10,6 @@ import { } from '@cowprotocol/common-utils' import { Address, - SupportedChainId as ChainId, CompetitionOrderStatus, CowEnv, EnrichedOrder, @@ -21,6 +20,7 @@ import { OrderQuoteSideKindSell, PartialApiContext, SigningScheme, + SupportedChainId as ChainId, TotalSurplus, Trade, } from '@cowprotocol/cow-sdk' @@ -31,10 +31,13 @@ import { LegacyFeeQuoteParams as FeeQuoteParams } from 'legacy/state/price/types import { getAppData } from 'modules/appData' +import { getQuoteValidFor } from 'utils/orderUtils/getQuoteValidFor' + import { ApiErrorCodes } from './errors/OperatorError' import QuoteApiError, { mapOperatorErrorToQuoteError, QuoteApiErrorDetails } from './errors/QuoteError' import { getIsOrderBookTypedError } from './getIsOrderBookTypedError' + function getProfileUrl(): Partial> { if (isLocal || isDev || isPr || isBarn) { return { @@ -70,7 +73,7 @@ function _fetchProfile( chainId: ChainId, url: string, method: 'GET' | 'POST' | 'DELETE', - data?: any + data?: any, ): Promise { const baseUrl = _getProfileApiBaseUrl(chainId) @@ -96,19 +99,8 @@ const ETH_FLOW_AUX_QUOTE_PARAMS = { } function _mapNewToLegacyParams(params: FeeQuoteParams): OrderQuoteRequest { - const { - amount, - kind, - userAddress, - receiver, - validTo, - validFor, - sellToken, - buyToken, - chainId, - priceQuality, - isEthFlow, - } = params + const { amount, kind, userAddress, receiver, validFor, sellToken, buyToken, chainId, priceQuality, isEthFlow } = + params const fallbackAddress = userAddress || ZERO_ADDRESS const { appData, appDataHash } = _getAppDataQuoteParams(params) @@ -122,7 +114,7 @@ function _mapNewToLegacyParams(params: FeeQuoteParams): OrderQuoteRequest { appDataHash, partiallyFillable: false, priceQuality, - ...(validFor ? { validFor } : { validTo }), + ...getQuoteValidFor(validFor), } if (isEthFlow) { @@ -172,7 +164,7 @@ export async function getQuote(params: FeeQuoteParams): Promise { return orderBookApi.getOrders(params, context) } @@ -227,7 +219,7 @@ export async function getSurplusData(chainId: ChainId, address: string): Promise export async function getOrderCompetitionStatus( chainId: ChainId, - orderId: string + orderId: string, ): Promise { try { return await orderBookApi.getOrderCompetitionStatus(orderId, { chainId }) diff --git a/apps/cowswap-frontend/src/common/updaters/FeesUpdater/isRefetchQuoteRequired.ts b/apps/cowswap-frontend/src/common/updaters/FeesUpdater/isRefetchQuoteRequired.ts index 5b4714631b..12aa904b67 100644 --- a/apps/cowswap-frontend/src/common/updaters/FeesUpdater/isRefetchQuoteRequired.ts +++ b/apps/cowswap-frontend/src/common/updaters/FeesUpdater/isRefetchQuoteRequired.ts @@ -8,8 +8,6 @@ import { quoteUsingSameParameters } from './quoteUsingSameParameters' const RENEW_FEE_QUOTES_BEFORE_EXPIRATION_TIME = ms`30s` // Will renew the quote if there's less than 30 seconds left for the quote to expire const WAITING_TIME_BETWEEN_EQUAL_REQUESTS = ms`5s` // Prevents from sending the same request to often (max, every 5s) -type FeeQuoteParams = Omit - /** * Returns if the quote has been recently checked */ @@ -30,7 +28,7 @@ function isExpiringSoon(quoteExpirationIsoDate: string, threshold: number): bool */ export function isRefetchQuoteRequired( isLoading: boolean, - currentParams: FeeQuoteParams, + currentParams: LegacyFeeQuoteParams, quoteInformation?: QuoteInformationObject, ): boolean { // If there's no quote/fee information, we always re-fetch diff --git a/apps/cowswap-frontend/src/common/updaters/FeesUpdater/quoteUsingSameParameters.ts b/apps/cowswap-frontend/src/common/updaters/FeesUpdater/quoteUsingSameParameters.ts index b41f5e0a66..4d43f12e5f 100644 --- a/apps/cowswap-frontend/src/common/updaters/FeesUpdater/quoteUsingSameParameters.ts +++ b/apps/cowswap-frontend/src/common/updaters/FeesUpdater/quoteUsingSameParameters.ts @@ -3,14 +3,15 @@ import { LegacyFeeQuoteParams } from 'legacy/state/price/types' import { decodeAppData } from 'modules/appData' -type FeeQuoteParams = Omit - /** * Checks if the parameters for the current quote are correct * * Quotes are only valid for a given token-pair and amount. If any of these parameter change, the fee needs to be re-fetched */ -export function quoteUsingSameParameters(currentParams: FeeQuoteParams, quoteInfo: QuoteInformationObject): boolean { +export function quoteUsingSameParameters( + currentParams: LegacyFeeQuoteParams, + quoteInfo: QuoteInformationObject, +): boolean { const { amount: currentAmount, sellToken: currentSellToken, diff --git a/apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater.ts b/apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater.ts index 033f4e14e5..7667007a5e 100644 --- a/apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater.ts +++ b/apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater.ts @@ -5,7 +5,6 @@ import { useTokensBalances } from '@cowprotocol/balances-and-allowances' import { NATIVE_CURRENCY_ADDRESS, WRAPPED_NATIVE_CURRENCIES } from '@cowprotocol/common-const' import { useIsWindowVisible } from '@cowprotocol/common-hooks' import { getPromiseFulfilledValue, isSellOrder } from '@cowprotocol/common-utils' -import { timestamp } from '@cowprotocol/contracts' import { PriceQuality, SupportedChainId as ChainId } from '@cowprotocol/cow-sdk' import { UiOrderType } from '@cowprotocol/types' import { useWalletInfo } from '@cowprotocol/wallet' @@ -22,7 +21,7 @@ import { getEstimatedExecutionPrice, getOrderMarketPrice, getRemainderAmount, - isOrderUnfillable, + isOrderUnfillable } from 'legacy/state/orders/utils' import type { LegacyFeeQuoteParams } from 'legacy/state/price/types' import { getBestQuote } from 'legacy/utils/price' @@ -222,13 +221,8 @@ async function _getOrderPrice(chainId: ChainId, order: Order, strategy: PriceStr } const legacyFeeQuoteParams = quoteParams as LegacyFeeQuoteParams - // Limit order may have arbitrary validTo, but API doesn't allow values greater than 1 hour - // To avoid ExcessiveValidTo error we use PRICE_QUOTE_VALID_TO_TIME - if (order.class === 'limit') { - legacyFeeQuoteParams.validFor = Math.round(PRICE_QUOTE_VALID_TO_TIME / 1000) - } else { - legacyFeeQuoteParams.validTo = timestamp(order.validTo) - } + + legacyFeeQuoteParams.validFor = Math.round(PRICE_QUOTE_VALID_TO_TIME / 1000) try { return getBestQuote({ strategy, quoteParams, fetchFee: false, isPriceRefresh: false }) diff --git a/apps/cowswap-frontend/src/legacy/utils/priceLegacy.ts b/apps/cowswap-frontend/src/legacy/utils/priceLegacy.ts index 93580d648c..5e38008d87 100644 --- a/apps/cowswap-frontend/src/legacy/utils/priceLegacy.ts +++ b/apps/cowswap-frontend/src/legacy/utils/priceLegacy.ts @@ -11,17 +11,18 @@ import { PriceInformation } from 'types' import { getPriceQuote as getPriceQuote1inch, PriceQuote1inch, - toPriceInformation as toPriceInformation1inch, + toPriceInformation as toPriceInformation1inch } from 'api/1inch' import { getQuote } from 'api/cowProtocol' import QuoteApiError, { QuoteApiErrorCodes } from 'api/cowProtocol/errors/QuoteError' +import { getQuoteValidFor } from 'utils/orderUtils/getQuoteValidFor' import { LegacyPriceInformationWithSource, LegacyPriceQuoteError, LegacyPriceQuoteParams, LegacyPromiseRejectedResultWithSource, - LegacyQuoteParams, + LegacyQuoteParams } from '../state/price/types' /** @@ -91,7 +92,7 @@ async function getAllPrices(params: LegacyPriceQuoteParams): Promise + oneInchPriceResult: PromiseSettledResult, ): [Array, Array] { // Prepare an array with all successful estimations const priceQuotes: Array = [] @@ -131,7 +132,7 @@ function _checkFeeErrorForData(error: QuoteApiError) { */ export async function getBestPrice( params: LegacyPriceQuoteParams, - options?: GetBestPriceOptions + options?: GetBestPriceOptions, ): Promise { // Get all prices const { oneInchPriceResult } = await getAllPrices(params) @@ -181,19 +182,8 @@ export async function getBestQuoteLegacy({ fetchFee, previousResponse, }: Omit): Promise { - const { - sellToken, - buyToken, - fromDecimals, - toDecimals, - amount, - kind, - chainId, - userAddress, - validTo, - validFor, - priceQuality, - } = quoteParams + const { sellToken, buyToken, fromDecimals, toDecimals, amount, kind, chainId, userAddress, validFor, priceQuality } = + quoteParams const { baseToken, quoteToken } = getCanonicalMarket({ sellToken, buyToken, kind }) // Get a new fee quote (if required) const feePromise = fetchFee || !previousResponse ? getQuote(quoteParams) : Promise.resolve(previousResponse) @@ -238,7 +228,7 @@ export async function getBestQuoteLegacy({ kind, userAddress, priceQuality, - ...(validFor ? { validFor } : { validTo }), + ...getQuoteValidFor(validFor), }) : // fee exceeds our price, is invalid Promise.reject(FEE_EXCEEDS_FROM_ERROR) diff --git a/apps/cowswap-frontend/src/utils/orderUtils/getQuoteValidFor.ts b/apps/cowswap-frontend/src/utils/orderUtils/getQuoteValidFor.ts new file mode 100644 index 0000000000..8352986f48 --- /dev/null +++ b/apps/cowswap-frontend/src/utils/orderUtils/getQuoteValidFor.ts @@ -0,0 +1,10 @@ +import ms from 'ms.macro' + +const MAX_QUOTE_DURATION = ms`3h` - ms`1min` + +export function getQuoteValidFor(validFor: number | undefined) { + if (validFor) { + return { validFor: Math.min(validFor, Math.floor(MAX_QUOTE_DURATION / 1000)) } + } + return +} From e1b74bc6bb3425737a920bae0ff69237c8823caf Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Fri, 18 Oct 2024 20:44:02 +0100 Subject: [PATCH 5/9] fix: always send validFor as is --- .../src/utils/orderUtils/getQuoteValidFor.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/apps/cowswap-frontend/src/utils/orderUtils/getQuoteValidFor.ts b/apps/cowswap-frontend/src/utils/orderUtils/getQuoteValidFor.ts index 8352986f48..9f8b140d2d 100644 --- a/apps/cowswap-frontend/src/utils/orderUtils/getQuoteValidFor.ts +++ b/apps/cowswap-frontend/src/utils/orderUtils/getQuoteValidFor.ts @@ -1,10 +1,3 @@ -import ms from 'ms.macro' - -const MAX_QUOTE_DURATION = ms`3h` - ms`1min` - export function getQuoteValidFor(validFor: number | undefined) { - if (validFor) { - return { validFor: Math.min(validFor, Math.floor(MAX_QUOTE_DURATION / 1000)) } - } - return + return validFor ? { validFor } : undefined } From ffade747d9630fc9a857630c08ce9b021acdc6af Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Fri, 18 Oct 2024 20:45:07 +0100 Subject: [PATCH 6/9] chore: formatting --- apps/cowswap-frontend/src/legacy/utils/trade.ts | 6 +++--- .../src/modules/limitOrders/services/tradeFlow/index.ts | 5 ++--- .../src/modules/tradeFlow/services/swapFlow/index.ts | 3 +-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/apps/cowswap-frontend/src/legacy/utils/trade.ts b/apps/cowswap-frontend/src/legacy/utils/trade.ts index f88cfde3fd..6184cf9e98 100644 --- a/apps/cowswap-frontend/src/legacy/utils/trade.ts +++ b/apps/cowswap-frontend/src/legacy/utils/trade.ts @@ -65,7 +65,7 @@ export function getOrderSubmitSummary( params: Pick< PostOrderParams, 'kind' | 'account' | 'inputAmount' | 'outputAmount' | 'recipient' | 'recipientAddressOrName' | 'feeAmount' - > + >, ): string { const { kind, account, inputAmount, outputAmount, recipient, recipientAddressOrName, feeAmount } = params @@ -249,7 +249,7 @@ export async function signAndPostOrder(params: PostOrderParams): Promise Date: Fri, 18 Oct 2024 21:23:22 +0100 Subject: [PATCH 7/9] fix: do not got over max order validity for quotes --- .../src/legacy/hooks/useRefetchPriceCallback.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/cowswap-frontend/src/legacy/hooks/useRefetchPriceCallback.tsx b/apps/cowswap-frontend/src/legacy/hooks/useRefetchPriceCallback.tsx index 9c0144dfd7..253f5dc137 100644 --- a/apps/cowswap-frontend/src/legacy/hooks/useRefetchPriceCallback.tsx +++ b/apps/cowswap-frontend/src/legacy/hooks/useRefetchPriceCallback.tsx @@ -16,18 +16,20 @@ import { QuoteError } from 'legacy/state/price/actions' import { useQuoteDispatchers } from 'legacy/state/price/hooks' import { QuoteInformationObject } from 'legacy/state/price/reducer' import { LegacyFeeQuoteParams, LegacyQuoteParams } from 'legacy/state/price/types' -import { useUserTransactionTTL } from 'legacy/state/user/hooks' import { getBestQuote, getFastQuote, QuoteResult } from 'legacy/utils/price' import { useIsEoaEthFlow } from 'modules/trade' import { ApiErrorCodes, isValidOperatorError } from 'api/cowProtocol/errors/OperatorError' import QuoteApiError, { + isValidQuoteError, QuoteApiErrorCodes, QuoteApiErrorDetails, - isValidQuoteError, } from 'api/cowProtocol/errors/QuoteError' +import { PRICE_QUOTE_VALID_TO_TIME } from '../../common/constants/quote' +import { useUserTransactionTTL } from '../state/user/hooks' + interface HandleQuoteErrorParams { quoteData: QuoteInformationObject | LegacyFeeQuoteParams error: unknown @@ -114,6 +116,8 @@ function handleQuoteError({ quoteData, error, addUnsupportedToken }: HandleQuote const getBestQuoteResolveOnlyLastCall = onlyResolvesLast(getBestQuote) const getFastQuoteResolveOnlyLastCall = onlyResolvesLast(getFastQuote) +const MAX_VALID_FOR = Math.round(PRICE_QUOTE_VALID_TO_TIME / 1000) + /** * @returns callback that fetches a new quote and update the state */ @@ -131,7 +135,7 @@ export function useRefetchQuoteCallback() { async (params: QuoteParamsForFetching) => { const { quoteParams, isPriceRefresh } = params // set the validTo time here - quoteParams.validFor = deadline + quoteParams.validFor = Math.min(deadline, MAX_VALID_FOR) // do not go over MAX_VALID_FOR quoteParams.isEthFlow = isEoaEthFlow let quoteData: LegacyFeeQuoteParams | QuoteInformationObject = quoteParams From f89a5db5bcae7425ea87bbd4ae7d3d1a57ac33c7 Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Fri, 18 Oct 2024 21:23:36 +0100 Subject: [PATCH 8/9] fix: remove validTo, no longer in use --- apps/cowswap-frontend/src/legacy/state/price/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/cowswap-frontend/src/legacy/state/price/types.ts b/apps/cowswap-frontend/src/legacy/state/price/types.ts index cc1f97fae0..8081221c24 100644 --- a/apps/cowswap-frontend/src/legacy/state/price/types.ts +++ b/apps/cowswap-frontend/src/legacy/state/price/types.ts @@ -20,7 +20,6 @@ interface FeeQuoteParams extends Pick Date: Tue, 22 Oct 2024 12:13:16 +0100 Subject: [PATCH 9/9] feat: use different max swap deadlines for SC and EOAs --- .../containers/TransactionSettings/index.tsx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx b/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx index 403c042989..e3fbe7b464 100644 --- a/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx +++ b/apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TransactionSettings/index.tsx @@ -16,7 +16,7 @@ import { useOnClickOutside } from '@cowprotocol/common-hooks' import { getWrappedToken, percentToBps } from '@cowprotocol/common-utils' import { StatefulValue } from '@cowprotocol/types' import { HelpTooltip, RowBetween, RowFixed, UI } from '@cowprotocol/ui' -import { useWalletInfo } from '@cowprotocol/wallet' +import { useIsSmartContractWallet, useWalletInfo } from '@cowprotocol/wallet' import { TradeType } from '@cowprotocol/widget-lib' import { Percent } from '@uniswap/sdk-core' @@ -48,7 +48,8 @@ import useNativeCurrency from 'lib/hooks/useNativeCurrency' import * as styledEl from './styled' -const MAX_DEADLINE_MINUTES = 60 * 12 // 12h +const MAX_EOA_DEADLINE_MINUTES = 60 * 3 // 3h +const MAX_SC_DEADLINE_MINUTES = 60 * 12 // 12h enum SlippageError { InvalidInput = 'InvalidInput', @@ -66,6 +67,7 @@ export function TransactionSettings({ deadlineState }: TransactionSettingsProps) const { chainId } = useWalletInfo() const theme = useContext(ThemeContext) + const isSmartContractWallet = useIsSmartContractWallet() const isEoaEthFlow = useIsEoaEthFlow() const nativeCurrency = useNativeCurrency() @@ -141,7 +143,7 @@ export function TransactionSettings({ deadlineState }: TransactionSettingsProps) ? // 10 minute low threshold for eth flow MINIMUM_ETH_FLOW_DEADLINE_SECONDS : MINIMUM_ORDER_VALID_TO_TIME_SECONDS - const maxDeadline = MAX_DEADLINE_MINUTES * 60 + const maxDeadline = (isSmartContractWallet ? MAX_SC_DEADLINE_MINUTES : MAX_EOA_DEADLINE_MINUTES) * 60 const parseCustomDeadline = useCallback( (value: string) => { @@ -149,16 +151,15 @@ export function TransactionSettings({ deadlineState }: TransactionSettingsProps) setDeadlineInput(value) setDeadlineError(false) - if (value.length === 0) { - orderExpirationTimeAnalytics('Default', DEFAULT_DEADLINE_FROM_NOW) - setDeadline(DEFAULT_DEADLINE_FROM_NOW) - } else { - try { - const parsed: number = Math.floor(Number.parseFloat(value) * 60) - if ( - !Number.isInteger(parsed) || // Check deadline is a number - parsed < - minDeadline || // Check deadline is not too small + if (value.length === 0) { + orderExpirationTimeAnalytics('Default', DEFAULT_DEADLINE_FROM_NOW) + setDeadline(DEFAULT_DEADLINE_FROM_NOW) + } else { + try { + const parsed: number = Math.floor(Number.parseFloat(value) * 60) + if ( + !Number.isInteger(parsed) || // Check deadline is a number + parsed < minDeadline || // Check deadline is not too small parsed > maxDeadline // Check deadline is not too big ) { setDeadlineError(DeadlineError.InvalidInput) @@ -280,8 +281,7 @@ export function TransactionSettings({ deadlineState }: TransactionSettingsProps) - CoW Swap has dynamically selected this slippage amount to - account for current gas prices and trade + CoW Swap has dynamically selected this slippage amount to account for current gas prices and trade size. Changes may result in slower execution. }