From 47195e2d326650a1fc11960077bd4861bdfcf418 Mon Sep 17 00:00:00 2001 From: Alexandr Kazachenko Date: Thu, 5 Dec 2024 14:17:44 +0500 Subject: [PATCH 01/11] fix(twap): fix orders fetching (#5157) --- apps/cowswap-frontend/src/api/cowProtocol/hooks.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/cowswap-frontend/src/api/cowProtocol/hooks.ts b/apps/cowswap-frontend/src/api/cowProtocol/hooks.ts index 019cdec863..7b18ca43c3 100644 --- a/apps/cowswap-frontend/src/api/cowProtocol/hooks.ts +++ b/apps/cowswap-frontend/src/api/cowProtocol/hooks.ts @@ -8,6 +8,8 @@ import { useSWROrdersRequest } from 'modules/orders/hooks/useSWROrdersRequest' import { getOrders } from './api' +const emptyOrders: EnrichedOrder[] = [] + export function useOrdersFromOrderBook(): EnrichedOrder[] { const { chainId } = useWalletInfo() @@ -17,8 +19,8 @@ export function useOrdersFromOrderBook(): EnrichedOrder[] { const { data: currentEnvOrders } = useSWR( requestParams && chainId ? ['orders', requestParams, chainId] : null, ([, params, _chainId]) => getOrders(params, { chainId: _chainId }), - { refreshInterval: ORDER_BOOK_API_UPDATE_INTERVAL } + { refreshInterval: ORDER_BOOK_API_UPDATE_INTERVAL, fallbackData: emptyOrders }, ) - return currentEnvOrders || [] + return currentEnvOrders } From d186042fc75c79ccd95defe30f6b5e0d17792f17 Mon Sep 17 00:00:00 2001 From: Alexandr Kazachenko Date: Thu, 5 Dec 2024 14:17:54 +0500 Subject: [PATCH 02/11] fix: update safe fee tooltip label (#5158) --- .../containers/TradeRateDetails/index.tsx | 3 -- .../TradeBasicConfirmDetails/index.tsx | 3 -- .../containers/TradeFeesAndCosts/index.tsx | 8 ++---- .../trade/pure/PartnerFeeRow/index.tsx | 12 ++++---- .../containers/TradeRateDetails/index.tsx | 3 -- .../volumeFee/hooks/useVolumeFeeTooltip.ts | 28 +++++++++++++++---- .../src/modules/volumeFee/index.ts | 1 + 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/apps/cowswap-frontend/src/modules/limitOrders/containers/TradeRateDetails/index.tsx b/apps/cowswap-frontend/src/modules/limitOrders/containers/TradeRateDetails/index.tsx index 1508275f31..8817f5a27a 100644 --- a/apps/cowswap-frontend/src/modules/limitOrders/containers/TradeRateDetails/index.tsx +++ b/apps/cowswap-frontend/src/modules/limitOrders/containers/TradeRateDetails/index.tsx @@ -1,6 +1,5 @@ import React, { useState, useCallback } from 'react' -import { useInjectedWidgetParams } from 'modules/injectedWidget' import { TradeTotalCostsDetails, PartnerFeeRow } from 'modules/trade' import { useUsdAmount } from 'modules/usdAmount' import { useVolumeFee, useVolumeFeeTooltip } from 'modules/volumeFee' @@ -15,7 +14,6 @@ interface TradeRateDetailsProps { export function TradeRateDetails({ rateInfoParams }: TradeRateDetailsProps) { const [isFeeDetailsOpen, setFeeDetailsOpen] = useState(false) - const widgetParams = useInjectedWidgetParams() const volumeFee = useVolumeFee() const partnerFeeAmount = useLimitOrderPartnerFeeAmount() const volumeFeeTooltip = useVolumeFeeTooltip() @@ -33,7 +31,6 @@ export function TradeRateDetails({ rateInfoParams }: TradeRateDetailsProps) { partnerFeeUsd={partnerFeeUsd} partnerFeeAmount={partnerFeeAmount} partnerFeeBps={partnerFeeBps} - widgetContent={widgetParams.content} volumeFeeTooltip={volumeFeeTooltip} /> ) diff --git a/apps/cowswap-frontend/src/modules/trade/containers/TradeBasicConfirmDetails/index.tsx b/apps/cowswap-frontend/src/modules/trade/containers/TradeBasicConfirmDetails/index.tsx index d636ab137b..adbbfb6a31 100644 --- a/apps/cowswap-frontend/src/modules/trade/containers/TradeBasicConfirmDetails/index.tsx +++ b/apps/cowswap-frontend/src/modules/trade/containers/TradeBasicConfirmDetails/index.tsx @@ -6,7 +6,6 @@ import { Percent, Price } from '@uniswap/sdk-core' import { Nullish } from 'types' -import { useInjectedWidgetParams } from 'modules/injectedWidget' import { useUsdAmount } from 'modules/usdAmount' import { useVolumeFeeTooltip } from 'modules/volumeFee' @@ -64,7 +63,6 @@ export function TradeBasicConfirmDetails(props: Props) { account, } = props const isInvertedState = useState(false) - const widgetParams = useInjectedWidgetParams() const volumeFeeTooltip = useVolumeFeeTooltip() const { amountAfterFees, amountAfterSlippage } = getOrderTypeReceiveAmounts(receiveAmountInfo) const { networkCostsSuffix, networkCostsTooltipSuffix } = labelsAndTooltips || {} @@ -106,7 +104,6 @@ export function TradeBasicConfirmDetails(props: Props) { networkCostsSuffix?: ReactNode networkCostsTooltipSuffix?: ReactNode withTimelineDot?: boolean alwaysRow?: boolean - volumeFeeTooltip?: string + volumeFeeTooltip: VolumeFeeTooltip } export function TradeFeesAndCosts(props: TradeFeesAndCostsProps) { const { receiveAmountInfo, - widgetParams, networkCostsSuffix, networkCostsTooltipSuffix, withTimelineDot = true, @@ -47,7 +44,6 @@ export function TradeFeesAndCosts(props: TradeFeesAndCostsProps) { partnerFeeUsd={partnerFeeUsd} partnerFeeAmount={partnerFeeAmount} partnerFeeBps={partnerFeeBps} - widgetContent={widgetParams.content} volumeFeeTooltip={volumeFeeTooltip} /> diff --git a/apps/cowswap-frontend/src/modules/trade/pure/PartnerFeeRow/index.tsx b/apps/cowswap-frontend/src/modules/trade/pure/PartnerFeeRow/index.tsx index fa693754c9..00f06173dd 100644 --- a/apps/cowswap-frontend/src/modules/trade/pure/PartnerFeeRow/index.tsx +++ b/apps/cowswap-frontend/src/modules/trade/pure/PartnerFeeRow/index.tsx @@ -1,10 +1,10 @@ import { bpsToPercent, formatPercent, FractionUtils } from '@cowprotocol/common-utils' -import { CowSwapWidgetContent } from '@cowprotocol/widget-lib' import { Currency, CurrencyAmount } from '@uniswap/sdk-core' import { Nullish } from 'types' import { WidgetMarkdownContent } from 'modules/injectedWidget' +import { VolumeFeeTooltip } from 'modules/volumeFee' import * as styledEl from '../../containers/TradeBasicConfirmDetails/styled' import { ReviewOrderModalAmountRow } from '../ReviewOrderModalAmountRow' @@ -15,8 +15,7 @@ interface PartnerFeeRowProps { partnerFeeBps: number | undefined withTimelineDot: boolean alwaysRow?: boolean - widgetContent?: CowSwapWidgetContent - volumeFeeTooltip?: string + volumeFeeTooltip: VolumeFeeTooltip } export function PartnerFeeRow({ @@ -25,7 +24,6 @@ export function PartnerFeeRow({ partnerFeeBps, withTimelineDot, alwaysRow, - widgetContent, volumeFeeTooltip, }: PartnerFeeRowProps) { const feeAsPercent = partnerFeeBps ? formatPercent(bpsToPercent(partnerFeeBps)) : null @@ -40,8 +38,8 @@ export function PartnerFeeRow({ fiatAmount={partnerFeeUsd} alwaysRow={alwaysRow} tooltip={ - volumeFeeTooltip ? ( - {volumeFeeTooltip} + volumeFeeTooltip.content ? ( + {volumeFeeTooltip.content} ) : ( <> This fee helps pay for maintenance & improvements to the trade experience. @@ -51,7 +49,7 @@ export function PartnerFeeRow({ ) } - label={`${widgetContent?.feeLabel || 'Total fee'} (${feeAsPercent}%)`} + label={`${volumeFeeTooltip.label} (${feeAsPercent}%)`} /> ) : ( : null} networkCostsTooltipSuffix={} diff --git a/apps/cowswap-frontend/src/modules/volumeFee/hooks/useVolumeFeeTooltip.ts b/apps/cowswap-frontend/src/modules/volumeFee/hooks/useVolumeFeeTooltip.ts index 750b3aa0b2..301567b23c 100644 --- a/apps/cowswap-frontend/src/modules/volumeFee/hooks/useVolumeFeeTooltip.ts +++ b/apps/cowswap-frontend/src/modules/volumeFee/hooks/useVolumeFeeTooltip.ts @@ -1,16 +1,34 @@ import { useAtomValue } from 'jotai' +import { useMemo } from 'react' + +import { useInjectedWidgetParams } from 'modules/injectedWidget' -import { useInjectedWidgetParams } from '../../injectedWidget' import { safeAppFeeAtom } from '../state/safeAppFeeAtom' -const SAFE_FEE_TOOLTIP = +const SAFE_FEE_TOOLTIP_CONTENT = 'The Safe App License Fee incurred here is charged by the Safe Foundation for the display of the app within their Safe Store. The fee is automatically calculated in this quote. Part of the fees will contribute to the CoW DAO treasury that supports the CoW Community.' +const SAFE_FEE_LABEL = 'Safe App License Fee' + +const SAFE_TOOLTIP = { + content: SAFE_FEE_TOOLTIP_CONTENT, + label: SAFE_FEE_LABEL, +} + +export interface VolumeFeeTooltip { + content: string | undefined + label: string +} -export function useVolumeFeeTooltip() { +export function useVolumeFeeTooltip(): VolumeFeeTooltip { const safeAppFee = useAtomValue(safeAppFeeAtom) const widgetParams = useInjectedWidgetParams() - if (safeAppFee) return SAFE_FEE_TOOLTIP + return useMemo(() => { + if (safeAppFee) return SAFE_TOOLTIP - return widgetParams.content?.feeTooltipMarkdown + return { + content: widgetParams.content?.feeTooltipMarkdown, + label: widgetParams.content?.feeLabel || 'Total fee', + } + }, [safeAppFee, widgetParams]) } diff --git a/apps/cowswap-frontend/src/modules/volumeFee/index.ts b/apps/cowswap-frontend/src/modules/volumeFee/index.ts index 6264d784eb..5032efb982 100644 --- a/apps/cowswap-frontend/src/modules/volumeFee/index.ts +++ b/apps/cowswap-frontend/src/modules/volumeFee/index.ts @@ -1,4 +1,5 @@ export { useVolumeFee } from './hooks/useVolumeFee' export { useVolumeFeeTooltip } from './hooks/useVolumeFeeTooltip' +export type { VolumeFeeTooltip } from './hooks/useVolumeFeeTooltip' export { volumeFeeAtom } from './state/volumeFeeAtom' export * from './types' From 4b9331cbfab92fc113043c4e204e280b55d09f62 Mon Sep 17 00:00:00 2001 From: Pedro Yves Fracari <55461956+yvesfracari@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:20:31 -0300 Subject: [PATCH 03/11] feat(hook-store): add cow amm deposit hook dapp (#5069) * feat: add cow amm deposit hook dapp * chore: remove hook dapp id --- libs/hook-dapp-lib/src/hookDappsRegistry.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libs/hook-dapp-lib/src/hookDappsRegistry.json b/libs/hook-dapp-lib/src/hookDappsRegistry.json index 9583278172..4ce8c5e3e2 100644 --- a/libs/hook-dapp-lib/src/hookDappsRegistry.json +++ b/libs/hook-dapp-lib/src/hookDappsRegistry.json @@ -91,5 +91,20 @@ "smartContractWalletSupported": false, "supportedNetworks": [1, 100, 42161] } + }, + "COW_AMM_DEPOSIT": { + "name": "CoW AMM Deposit", + "type": "IFRAME", + "descriptionShort": "Add liquidity to any of the CoW AMM pools", + "description": "Easily increase your position in a liquidity pool, adding both tokens in the right ratio.\n\n Whether you're seeking to increase your exposure to specific tokens or maximize the returns from your assets, this tool offers a quick and efficient way to enhance your liquidity position after a token swap, all in a smooth, efficient process.", + "version": "0.0.1", + "website": "https://balancer.fi/pools/cow", + "image": "https://cow-hooks-dapps-cow-amm-deposit.vercel.app/icon.png", + "url": "https://cow-hooks-dapps-cow-amm-deposit.vercel.app/", + "conditions": { + "position": "post", + "walletCompatibility": ["EOA"], + "smartContractWalletSupported": false + } } } From fa7a5f551be89737a72ad5e6392e744ad44aa03c Mon Sep 17 00:00:00 2001 From: Alexandr Kazachenko Date: Thu, 5 Dec 2024 14:47:53 +0500 Subject: [PATCH 04/11] chore: release main (#5160) --- .release-please-manifest.json | 2 +- apps/cowswap-frontend/CHANGELOG.md | 8 ++++++++ apps/cowswap-frontend/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 342a031dae..5f56638580 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,5 +1,5 @@ { - "apps/cowswap-frontend": "1.92.0", + "apps/cowswap-frontend": "1.92.1", "apps/explorer": "2.38.0", "libs/permit-utils": "0.5.0", "libs/widget-lib": "0.18.0", diff --git a/apps/cowswap-frontend/CHANGELOG.md b/apps/cowswap-frontend/CHANGELOG.md index b781be6a27..caca590e19 100644 --- a/apps/cowswap-frontend/CHANGELOG.md +++ b/apps/cowswap-frontend/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [1.92.1](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.92.0...cowswap-v1.92.1) (2024-12-05) + + +### Bug Fixes + +* **twap:** fix orders fetching ([#5157](https://github.com/cowprotocol/cowswap/issues/5157)) ([47195e2](https://github.com/cowprotocol/cowswap/commit/47195e2d326650a1fc11960077bd4861bdfcf418)) +* update safe fee tooltip label ([#5158](https://github.com/cowprotocol/cowswap/issues/5158)) ([d186042](https://github.com/cowprotocol/cowswap/commit/d186042fc75c79ccd95defe30f6b5e0d17792f17)) + ## [1.92.0](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.91.0...cowswap-v1.92.0) (2024-12-04) diff --git a/apps/cowswap-frontend/package.json b/apps/cowswap-frontend/package.json index 69689bc88b..78f7046c8e 100644 --- a/apps/cowswap-frontend/package.json +++ b/apps/cowswap-frontend/package.json @@ -1,6 +1,6 @@ { "name": "@cowprotocol/cowswap", - "version": "1.92.0", + "version": "1.92.1", "description": "CoW Swap", "main": "index.js", "author": "", From cefdb55475f4989d745857fc9f8f2cfa77be5243 Mon Sep 17 00:00:00 2001 From: Alexandr Kazachenko Date: Thu, 5 Dec 2024 18:14:55 +0500 Subject: [PATCH 05/11] fix: add safe apps fee in Base network (#5161) --- .../src/modules/volumeFee/state/safeAppFeeAtom.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/cowswap-frontend/src/modules/volumeFee/state/safeAppFeeAtom.ts b/apps/cowswap-frontend/src/modules/volumeFee/state/safeAppFeeAtom.ts index 49cde96315..44ac4b1350 100644 --- a/apps/cowswap-frontend/src/modules/volumeFee/state/safeAppFeeAtom.ts +++ b/apps/cowswap-frontend/src/modules/volumeFee/state/safeAppFeeAtom.ts @@ -1,12 +1,14 @@ import { atom } from 'jotai' import { STABLECOINS } from '@cowprotocol/common-const' -import { getCurrencyAddress } from '@cowprotocol/common-utils' -import { OrderKind, SupportedChainId } from '@cowprotocol/cow-sdk' +import { getCurrencyAddress, isInjectedWidget } from '@cowprotocol/common-utils' +import { OrderKind } from '@cowprotocol/cow-sdk' import { walletDetailsAtom, walletInfoAtom } from '@cowprotocol/wallet' -import { featureFlagsAtom } from '../../../common/state/featureFlagsState' -import { derivedTradeStateAtom } from '../../trade' +import { derivedTradeStateAtom } from 'modules/trade' + +import { featureFlagsAtom } from 'common/state/featureFlagsState' + import { VolumeFee } from '../types' const SAFE_FEE_RECIPIENT = '0x63695Eee2c3141BDE314C5a6f89B98E62808d716' @@ -39,9 +41,8 @@ export const safeAppFeeAtom = atom((get) => { const { isSafeAppFeeEnabled } = get(featureFlagsAtom) const { inputCurrency, outputCurrency, inputCurrencyFiatAmount, outputCurrencyFiatAmount, orderKind } = get(derivedTradeStateAtom) || {} - const isBaseNetwork = chainId === SupportedChainId.BASE - if (!isSafeApp || !isSafeAppFeeEnabled || isBaseNetwork) return null + if (!isSafeApp || !isSafeAppFeeEnabled || isInjectedWidget()) return null const fiatCurrencyValue = orderKind === OrderKind.SELL ? inputCurrencyFiatAmount : outputCurrencyFiatAmount const fiatAmount = fiatCurrencyValue ? +fiatCurrencyValue.toExact() : null From 8f1b3f999581f341f81f63fa01027168e77fde46 Mon Sep 17 00:00:00 2001 From: Alexandr Kazachenko Date: Thu, 5 Dec 2024 18:20:03 +0500 Subject: [PATCH 06/11] chore: release main (#5162) --- .release-please-manifest.json | 2 +- apps/cowswap-frontend/CHANGELOG.md | 7 +++++++ apps/cowswap-frontend/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 5f56638580..1c12e6f659 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,5 +1,5 @@ { - "apps/cowswap-frontend": "1.92.1", + "apps/cowswap-frontend": "1.92.2", "apps/explorer": "2.38.0", "libs/permit-utils": "0.5.0", "libs/widget-lib": "0.18.0", diff --git a/apps/cowswap-frontend/CHANGELOG.md b/apps/cowswap-frontend/CHANGELOG.md index caca590e19..da733284ed 100644 --- a/apps/cowswap-frontend/CHANGELOG.md +++ b/apps/cowswap-frontend/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.92.2](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.92.1...cowswap-v1.92.2) (2024-12-05) + + +### Bug Fixes + +* add safe apps fee in Base network ([#5161](https://github.com/cowprotocol/cowswap/issues/5161)) ([cefdb55](https://github.com/cowprotocol/cowswap/commit/cefdb55475f4989d745857fc9f8f2cfa77be5243)) + ## [1.92.1](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.92.0...cowswap-v1.92.1) (2024-12-05) diff --git a/apps/cowswap-frontend/package.json b/apps/cowswap-frontend/package.json index 78f7046c8e..e854f7cc48 100644 --- a/apps/cowswap-frontend/package.json +++ b/apps/cowswap-frontend/package.json @@ -1,6 +1,6 @@ { "name": "@cowprotocol/cowswap", - "version": "1.92.1", + "version": "1.92.2", "description": "CoW Swap", "main": "index.js", "author": "", From 1181cbcfeb460eb659938746cf9dad522622dab4 Mon Sep 17 00:00:00 2001 From: Anxo Rodriguez Date: Thu, 5 Dec 2024 13:40:51 +0000 Subject: [PATCH 07/11] feat: handle errors for decoding conditional orders (#5152) --- apps/sdk-tools/src/SdkTools.tsx | 93 +++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 4 deletions(-) diff --git a/apps/sdk-tools/src/SdkTools.tsx b/apps/sdk-tools/src/SdkTools.tsx index d7592e363e..1f67c9e240 100644 --- a/apps/sdk-tools/src/SdkTools.tsx +++ b/apps/sdk-tools/src/SdkTools.tsx @@ -122,6 +122,29 @@ const Value = styled.span` color: #666; ` +const ErrorContainer = styled.div` + margin-top: 20px; + padding: 20px; + border: 1px solid #f00; + border-radius: 4px; + background-color: #fee; + width: 100%; +` + +const ErrorTitle = styled.h3` + margin-bottom: 10px; + color: #f00; +` + +const ErrorText = styled.div` + color: #f00; + word-break: break-all; +` + +const ButtonContainer = styled.div` + margin-top: 20px; +` + function IsValid({ isValid }: { isValid: IsValidResult }) { if (isValid.isValid) { return true @@ -141,16 +164,68 @@ export function SdkTools() { '0x000000000000000000000000cb444e90d8198415266c6a2724b7900fb12fc56e000000000000000000000000a0f8904ec48a2775b8a88b40e9c171f05f7d767300000000000000000000000042cedde51198d1773590311e2a340dc06b24cb370000000000000000000000000000000000000000000000004563918244f400000000000000000000000000000000000000000000000000006f30c3f95f913d84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000057e400000000000000000000000000000000000000000000000000000000000000000b051c2da471b8bc8b993fd373b5e6ae8b9aaea1b7a781f0fd41f7f2af7c0bda1', ) const [conditionalOrder, setConditionalOrder] = React.useState | undefined>() + const [error, setError] = React.useState() const handleSubmit = (e: React.FormEvent) => { e.preventDefault() + setError(undefined) + setConditionalOrder(undefined) + console.log('Handler:', handler) console.log('Salt:', salt) console.log('Static Input:', staticInput) - const conditionalOrder = ordersFactory.fromParams({ handler, salt, staticInput }) - setConditionalOrder(conditionalOrder) - console.log('Conditional Order:', conditionalOrder) + try { + const conditionalOrder = ordersFactory.fromParams({ handler, salt, staticInput }) + + if (conditionalOrder) { + console.log('Conditional Order:', conditionalOrder) + setConditionalOrder(conditionalOrder) + } else { + setError( + <> +

+ The SDK don't know how to handle this order. Please check the supported programmatic orders in the{' '} + + Conditional Order Registry + + . +

{' '} +

+ If the SDK should know how to handle it, please{' '} + + consider adding it yourself + + . +

+

+ If the SDK don't support the order, it doesn't mean that is not handled by{' '} + + watch-tower + + , but it means that the processing of the order might be more inefficient, and the logs will be harder to + debug. +

+ , + ) + } + } catch (e) { + console.error(e) + setError( + <> +

Error decoding the conditional order parameters

+ {e.message &&

{e.message}

} + , + ) + } } return ( @@ -172,7 +247,17 @@ export function SdkTools() { Static Input: