Skip to content

Commit

Permalink
chore: merge into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
yvesfracari committed Oct 22, 2024
2 parents 22501d4 + 9308fc1 commit c80d504
Show file tree
Hide file tree
Showing 218 changed files with 3,072 additions and 2,647 deletions.
16 changes: 8 additions & 8 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"apps/cowswap-frontend": "1.85.0",
"apps/explorer": "2.35.1",
"apps/cowswap-frontend": "1.86.1",
"apps/explorer": "2.36.0",
"libs/permit-utils": "0.4.0",
"libs/widget-lib": "0.15.0",
"libs/widget-lib": "0.16.0",
"libs/widget-react": "0.11.0",
"apps/widget-configurator": "1.7.2",
"apps/widget-configurator": "1.8.0",
"libs/analytics": "1.8.0",
"libs/assets": "1.8.0",
"libs/common-const": "1.7.0",
"libs/common-const": "1.8.0",
"libs/common-hooks": "1.4.0",
"libs/common-utils": "1.7.2",
"libs/core": "1.3.0",
Expand All @@ -16,13 +16,13 @@
"libs/snackbars": "1.1.0",
"libs/tokens": "1.10.0",
"libs/types": "1.2.0",
"libs/ui": "1.10.1",
"libs/wallet": "1.6.0",
"libs/ui": "1.11.0",
"libs/wallet": "1.6.1",
"apps/cow-fi": "1.15.0",
"libs/wallet-provider": "1.0.0",
"libs/ui-utils": "1.1.0",
"libs/abis": "1.2.0",
"libs/balances-and-allowances": "1.0.0",
"libs/iframe-transport": "1.0.0",
"libs/hook-dapp-lib": "1.1.0"
"libs/hook-dapp-lib": "1.2.0"
}
26 changes: 26 additions & 0 deletions apps/cowswap-frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## [1.86.1](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.86.0...cowswap-v1.86.1) (2024-10-18)


### Bug Fixes

* **widget:** ignore selected eip6963 provider when in widget ([#5009](https://github.com/cowprotocol/cowswap/issues/5009)) ([3f8446b](https://github.com/cowprotocol/cowswap/commit/3f8446b48a4f493448b262959b943756a24382d9))

## [1.86.0](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.85.0...cowswap-v1.86.0) (2024-10-18)


### Features

* display new label for cow amm ([#4994](https://github.com/cowprotocol/cowswap/issues/4994)) ([531e63f](https://github.com/cowprotocol/cowswap/commit/531e63f666ffcafdaf8e2b1c2850991facbe5cf1))
* **hooks-store:** add claim vesting iframe hook ([#4924](https://github.com/cowprotocol/cowswap/issues/4924)) ([395f48f](https://github.com/cowprotocol/cowswap/commit/395f48f57d93de67305791fdb9a668bdd693074e))
* **hooks-store:** add sell/buy amounts to hook-dapp context ([#4990](https://github.com/cowprotocol/cowswap/issues/4990)) ([26cbffb](https://github.com/cowprotocol/cowswap/commit/26cbffbbfe8edbc0a4a9ba31fe9c0d42852118d9))
* **slippage:** small order slippage v2 ([#4934](https://github.com/cowprotocol/cowswap/issues/4934)) ([7b2a49c](https://github.com/cowprotocol/cowswap/commit/7b2a49c41ecfd62107a3128e771003743094d246))
* **smart-slippage:** update smart slippage text ([#4982](https://github.com/cowprotocol/cowswap/issues/4982)) ([4b89ecb](https://github.com/cowprotocol/cowswap/commit/4b89ecbf661e6c30193586c704e23c78b2bfc22b))
* **widget:** deadline widget param ([#4991](https://github.com/cowprotocol/cowswap/issues/4991)) ([ce3b5b8](https://github.com/cowprotocol/cowswap/commit/ce3b5b8adb5cc95a5ca3097d5cf2d45b249748c2))
* **widget:** hide bridge info ([#4992](https://github.com/cowprotocol/cowswap/issues/4992)) ([9842afd](https://github.com/cowprotocol/cowswap/commit/9842afdb887497d235a01538663488b0b8852bb5))
* **widget:** hide orders table ([#4993](https://github.com/cowprotocol/cowswap/issues/4993)) ([681fb20](https://github.com/cowprotocol/cowswap/commit/681fb20dab0b4155d50ad7f32c7a48cb95e084a3))


### Bug Fixes

* **smart-slippage:** fix smart slip tooltip and feature flag ([#5004](https://github.com/cowprotocol/cowswap/issues/5004)) ([c6ea5af](https://github.com/cowprotocol/cowswap/commit/c6ea5af5d24b9a806540d53d2a0d9e12799d4eff))

## [1.85.0](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.84.0...cowswap-v1.85.0) (2024-10-10)


Expand Down
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cowprotocol/cowswap",
"version": "1.85.0",
"version": "1.86.1",
"description": "CoW Swap",
"main": "index.js",
"author": "",
Expand Down
8 changes: 8 additions & 0 deletions apps/cowswap-frontend/src/common/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const Routes = {
SWAP: `/:chainId?${TRADE_WIDGET_PREFIX}/swap/:inputCurrencyId?/:outputCurrencyId?`,
HOOKS: `/:chainId?${TRADE_WIDGET_PREFIX}/swap/hooks/:inputCurrencyId?/:outputCurrencyId?`,
LIMIT_ORDER: `/:chainId?${TRADE_WIDGET_PREFIX}/limit/:inputCurrencyId?/:outputCurrencyId?`,
YIELD: `/:chainId?${TRADE_WIDGET_PREFIX}/yield/:inputCurrencyId?/:outputCurrencyId?`,
ADVANCED_ORDERS: `/:chainId?${TRADE_WIDGET_PREFIX}/advanced/:inputCurrencyId?/:outputCurrencyId?`,
LONG_LIMIT_ORDER: `/:chainId?${TRADE_WIDGET_PREFIX}/limit-orders/:inputCurrencyId?/:outputCurrencyId?`,
LONG_ADVANCED_ORDERS: `/:chainId?${TRADE_WIDGET_PREFIX}/advanced-orders/:inputCurrencyId?/:outputCurrencyId?`,
Expand Down Expand Up @@ -55,3 +56,10 @@ export const HOOKS_STORE_MENU_ITEM = {
description: 'Powerful tool to generate pre/post interaction for CoW Protocol',
badge: 'New',
}

export const YIELD_MENU_ITEM = {
route: Routes.YIELD,
label: 'Yield',
fullLabel: 'Yield',
description: 'Provide liquidity',
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const widgetTypeMap: Record<TradeType, string> = {
[TradeType.LIMIT_ORDER]: 'LIMIT',
// TODO: set different type for other advanced orders
[TradeType.ADVANCED_ORDERS]: 'TWAP',
[TradeType.YIELD]: 'YIELD',
}

/**\
Expand Down
17 changes: 14 additions & 3 deletions apps/cowswap-frontend/src/common/hooks/useMenuItems.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import { useMemo } from 'react'

import { useFeatureFlags } from '@cowprotocol/common-hooks'
import { isLocal } from '@cowprotocol/common-utils'
import { isLocal, isPr } from '@cowprotocol/common-utils'

import { HOOKS_STORE_MENU_ITEM, MENU_ITEMS } from '../constants/routes'
import { HOOKS_STORE_MENU_ITEM, MENU_ITEMS, YIELD_MENU_ITEM } from '../constants/routes'

export function useMenuItems() {
const { isHooksStoreEnabled } = useFeatureFlags()
const { isYieldEnabled } = useFeatureFlags()

return useMemo(() => {
return isHooksStoreEnabled || isLocal ? MENU_ITEMS.concat(HOOKS_STORE_MENU_ITEM) : MENU_ITEMS
const items = [...MENU_ITEMS]

if (isHooksStoreEnabled || isLocal) {
items.push(HOOKS_STORE_MENU_ITEM)
}

if (isYieldEnabled || isLocal || isPr) {
items.push(YIELD_MENU_ITEM)
}

return items
}, [isHooksStoreEnabled])
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { SupportedChainId as ChainId } from '@cowprotocol/cow-sdk'
import { SupportedChainId, SupportedChainId as ChainId } from '@cowprotocol/cow-sdk'
import { Command } from '@cowprotocol/types'
import { BackButton } from '@cowprotocol/ui'
import { Currency } from '@uniswap/sdk-core'

import { Nullish } from 'types'

import { DisplayLink } from 'legacy/components/TransactionConfirmationModal/DisplayLink'
import { ActivityStatus } from 'legacy/hooks/useRecentActivity'
import type { Order } from 'legacy/state/orders/actions'

import { ActivityDerivedState } from 'modules/account/containers/Transaction'
import { GnosisSafeTxDetails } from 'modules/account/containers/Transaction/ActivityDetails'
import { Category, cowAnalytics } from 'modules/analytics'
import { EthFlowStepper } from 'modules/swap/containers/EthFlowStepper'
import { NavigateToNewOrderCallback } from 'modules/swap/hooks/useNavigateToNewOrderCallback'
import { WatchAssetInWallet } from 'modules/wallet/containers/WatchAssetInWallet'

import * as styledEl from './styled'
Expand Down Expand Up @@ -46,7 +47,7 @@ export interface TransactionSubmittedContentProps {
activityDerivedState: ActivityDerivedState | null
currencyToAdd?: Nullish<Currency>
orderProgressBarV2Props: OrderProgressBarV2Props
navigateToNewOrderCallback?: NavigateToNewOrderCallback
navigateToNewOrderCallback?: (chainId: SupportedChainId, order?: Order, callback?: Command) => () => void
}

export function TransactionSubmittedContent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { Field } from 'legacy/state/types'
import { useUserTransactionTTL } from 'legacy/state/user/hooks'

import { useAppData } from 'modules/appData'
import { useIsEoaEthFlow } from 'modules/swap/hooks/useIsEoaEthFlow'
import { useDerivedSwapInfo, useSwapState } from 'modules/swap/hooks/useSwapState'
import { useIsEoaEthFlow } from 'modules/trade'

import { isRefetchQuoteRequired } from './isRefetchQuoteRequired'
import { quoteUsingSameParameters } from './quoteUsingSameParameters'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async function _updatePresignGnosisSafeTx(
getSafeTxInfo: GetSafeTxInfo,
updatePresignGnosisSafeTx: UpdatePresignGnosisSafeTxCallback,
cancelOrdersBatch: CancelOrdersBatchCallback,
safeInfo: GnosisSafeInfo | undefined
safeInfo: GnosisSafeInfo | undefined,
) {
const getSafeTxPromises = allPendingOrders
// Update orders that are pending for presingature
Expand Down Expand Up @@ -100,7 +100,7 @@ async function _updatePresignGnosisSafeTx(
if (!error.isCancelledError) {
console.error(
`[PendingOrdersUpdater] Failed to check Gnosis Safe tx hash: ${presignGnosisSafeTxHash}`,
error
error,
)
}
})
Expand All @@ -113,7 +113,7 @@ async function _updateCreatingOrders(
chainId: ChainId,
pendingOrders: Order[],
isSafeWallet: boolean,
addOrUpdateOrders: AddOrUpdateOrdersCallback
addOrUpdateOrders: AddOrUpdateOrdersCallback,
): Promise<void> {
const promises = pendingOrders.reduce<Promise<void>[]>((acc, order) => {
if (order.status === OrderStatus.CREATING) {
Expand Down Expand Up @@ -205,7 +205,7 @@ async function _updateOrders({

// Iterate over pending orders fetching API data
const unfilteredOrdersData = await Promise.all(
pending.map(async (orderFromStore) => fetchAndClassifyOrder(orderFromStore, chainId))
pending.map(async (orderFromStore) => fetchAndClassifyOrder(orderFromStore, chainId)),
)

// Group resolved promises by status
Expand All @@ -219,7 +219,7 @@ async function _updateOrders({
}
return acc
},
{ fulfilled: [], expired: [], cancelled: [], unknown: [], presigned: [], pending: [], presignaturePending: [] }
{ fulfilled: [], expired: [], cancelled: [], unknown: [], presigned: [], pending: [], presignaturePending: [] },
)

if (presigned.length > 0) {
Expand Down Expand Up @@ -310,15 +310,15 @@ async function _updateOrders({
getSafeTxInfo,
updatePresignGnosisSafeTx,
cancelOrdersBatch,
safeInfo
safeInfo,
)
// Update the creating EthFlow orders (if any)
await _updateCreatingOrders(chainId, orders, isSafeWallet, addOrUpdateOrders)
}

function getReplacedOrCancelledEthFlowOrders(
orders: Order[],
allTransactions: UpdateOrdersParams['allTransactions']
allTransactions: UpdateOrdersParams['allTransactions'],
): Order[] {
return orders.filter((order) => {
if (!order.orderCreationHash || order.status !== OrderStatus.CREATING) return false
Expand Down Expand Up @@ -373,15 +373,17 @@ export function PendingOrdersUpdater(): null {
const isUpdatingLimit = useRef(false)
const isUpdatingTwap = useRef(false)
const isUpdatingHooks = useRef(false)
const isUpdatingYield = useRef(false)

const updatersRefMap = useMemo(
() => ({
[UiOrderType.SWAP]: isUpdatingMarket,
[UiOrderType.LIMIT]: isUpdatingLimit,
[UiOrderType.TWAP]: isUpdatingTwap,
[UiOrderType.HOOKS]: isUpdatingHooks,
[UiOrderType.YIELD]: isUpdatingYield,
}),
[]
[],
)

// Ref, so we don't rerun useEffect
Expand Down Expand Up @@ -411,7 +413,7 @@ export function PendingOrdersUpdater(): null {
// Remove orders from the cancelling queue (marked by checkbox in the orders table)
removeOrdersToCancel(fulfillOrdersBatchParams.orders.map(({ uid }) => uid))
},
[chainId, _fulfillOrdersBatch, removeOrdersToCancel]
[chainId, _fulfillOrdersBatch, removeOrdersToCancel],
)

const updateOrders = useCallback(
Expand Down Expand Up @@ -460,7 +462,7 @@ export function PendingOrdersUpdater(): null {
getSafeTxInfo,
safeInfo,
allTransactions,
]
],
)

useEffect(() => {
Expand All @@ -470,15 +472,15 @@ export function PendingOrdersUpdater(): null {

const marketInterval = setInterval(
() => updateOrders(chainId, account, isSafeWallet, UiOrderType.SWAP),
MARKET_OPERATOR_API_POLL_INTERVAL
MARKET_OPERATOR_API_POLL_INTERVAL,
)
const limitInterval = setInterval(
() => updateOrders(chainId, account, isSafeWallet, UiOrderType.LIMIT),
LIMIT_OPERATOR_API_POLL_INTERVAL
LIMIT_OPERATOR_API_POLL_INTERVAL,
)
const twapInterval = setInterval(
() => updateOrders(chainId, account, isSafeWallet, UiOrderType.TWAP),
LIMIT_OPERATOR_API_POLL_INTERVAL
LIMIT_OPERATOR_API_POLL_INTERVAL,
)

updateOrders(chainId, account, isSafeWallet, UiOrderType.SWAP)
Expand Down
71 changes: 71 additions & 0 deletions apps/cowswap-frontend/src/common/utils/tradeSettingsTooltips.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import {
INPUT_OUTPUT_EXPLANATION,
MINIMUM_ETH_FLOW_DEADLINE_SECONDS,
MINIMUM_ETH_FLOW_SLIPPAGE,
PERCENTAGE_PRECISION,
} from '@cowprotocol/common-const'
import { SupportedChainId } from '@cowprotocol/cow-sdk'

import { Trans } from '@lingui/macro'

export function getNativeOrderDeadlineTooltip(symbols: (string | undefined)[] | undefined) {
return (
<Trans>
{symbols?.[0] || 'Native currency (e.g ETH)'} orders require a minimum transaction expiration time threshold of{' '}
{MINIMUM_ETH_FLOW_DEADLINE_SECONDS / 60} minutes to ensure the best swapping experience.
<br />
<br />
Orders not matched after the threshold time are automatically refunded.
</Trans>
)
}

export function getNonNativeOrderDeadlineTooltip() {
return (
<Trans>
Your swap expires and will not execute if it is pending for longer than the selected duration.
<br />
<br />
{INPUT_OUTPUT_EXPLANATION}
</Trans>
)
}

export const getNativeSlippageTooltip = (chainId: SupportedChainId, symbols: (string | undefined)[] | undefined) => (
<Trans>
When selling {symbols?.[0] || 'a native currency'}, the minimum slippage tolerance is set to{' '}
{MINIMUM_ETH_FLOW_SLIPPAGE[chainId].toSignificant(PERCENTAGE_PRECISION)}% to ensure a high likelihood of order
matching, even in volatile market conditions.
<br />
<br />
{symbols?.[0] || 'Native currency'} orders can, in rare cases, be frontrun due to their on-chain component. For more
robust MEV protection, consider wrapping your {symbols?.[0] || 'native currency'} before trading.
</Trans>
)

export const getNonNativeSlippageTooltip = (params?: { isDynamic?: boolean; isSettingsModal?: boolean }) => (
<Trans>
{params?.isDynamic ? (
<>
CoW Swap dynamically adjusts your slippage tolerance to ensure your trade executes quickly while still getting
the best price.{' '}
{params?.isSettingsModal ? (
<>
To override this, enter your desired slippage amount.
<br />
<br />
Either way, your slippage is protected from MEV!
</>
) : (
<>
<br />
<br />
Trades are protected from MEV, so your slippage can't be exploited!
</>
)}
</>
) : (
<>CoW Swap trades are protected from MEV, so your slippage can't be exploited!</>
)}
</Trans>
)
7 changes: 6 additions & 1 deletion apps/cowswap-frontend/src/cow-react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ function Main() {

function Web3ProviderInstance({ children }: { children: ReactNode }) {
const selectedWallet = useAppSelector((state) => state.user.selectedWallet)
const { standaloneMode } = useInjectedWidgetParams()

return <Web3Provider selectedWallet={selectedWallet}>{children}</Web3Provider>
return (
<Web3Provider standaloneMode={standaloneMode} selectedWallet={selectedWallet}>
{children}
</Web3Provider>
)
}

function Toasts() {
Expand Down
Loading

0 comments on commit c80d504

Please sign in to comment.