Skip to content

Conversation

@anxolin
Copy link
Contributor

@anxolin anxolin commented Nov 4, 2025

Summary

  1. Added Near intents bridge provider from Substance labs feat/near intents cow-sdk#642
  2. Since this provider is not hooks-based, I added providerId parameter to appData.metadata.bridging. This value is used to link an order with bridge provider
  3. Improved BridgingSdk multiprovider support. Now we load tokens and target networks for all enabled providers.
  4. Added feature-flags per each bridge provider, see the list below.
  5. Removed isBridgingEnabled feature-flag

Feature-flags

Never disable the Bungee feature-flag on Prod! And do not enable other providers on Prod till we decide to do that.

If no one bridge-provider feature-flag is enabled, then CoW Swap will use all the providers.

Summary by CodeRabbit

  • New Features

    • Added Across and Near Intents bridge providers; receiver-account bridge flow now shows a "Preparing deposit" signing step.
    • Improved support for intermediate currencies with correct fee handling across differing token decimals.
  • Bug Fixes

    • Bridging now enables based on wallet compatibility and route (no feature-flag gate).
    • Improved quote/fee accuracy and clearer bridge error messages and tooltips (missing intermediate tokens, deposit verification).

@vercel
Copy link

vercel bot commented Nov 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
cowfi Ready Ready Preview Nov 14, 2025 0:02am
explorer-dev Ready Ready Preview Nov 14, 2025 0:02am
swap-dev Ready Ready Preview Nov 14, 2025 0:02am
widget-configurator Ready Ready Preview Nov 14, 2025 0:02am
2 Skipped Deployments
Project Deployment Preview Updated (UTC)
cosmos Ignored Ignored Nov 14, 2025 0:02am
sdk-tools Ignored Ignored Preview Nov 14, 2025 0:02am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 4, 2025

Warning

Rate limit exceeded

@shoom3301 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 75a51b2 and 66577c7.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • package.json (1 hunks)

Walkthrough

Bridging was reworked: feature-flag gating removed, provider management centralized via a new updater and bridging SDK calls, bridge fee handling extended to per-currency breakdowns with decimal alignment, recipient/signing flows adjusted for a ReceiverAccountBridgeProvider, and several hooks/atoms/tests moved or removed.

Changes

Cohort / File(s) Summary
Bridge Provider Core Infrastructure
apps/cowswap-frontend/src/entities/bridgeProvider/bridgeProvidersAtom.ts, apps/cowswap-frontend/src/entities/bridgeProvider/BridgeProvidersUpdater.ts, apps/cowswap-frontend/src/entities/bridgeProvider/index.ts
Replaced conditional array with a Set-based atom containing bungee provider. Added BridgeProvidersUpdater to read feature flags and call bridgingSdk.setAvailableProviders; re-exported updater.
Bridge Provider Hooks
apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeProviders.ts, apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeProvidersIds.ts
Removed useBridgeProviders hook. Added useBridgeProvidersIds returning provider dappId array for SDK-based fetch keys.
Network/Token Discovery
apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.ts, apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedTokens.ts, .../useBridgeSupportedNetworks.test.tsx, .../useBridgeSupportedTokens.test.tsx
Switched from per-provider Promise.allSettled aggregation to single bridgingSdk calls keyed by provider IDs. Removed corresponding tests. Token responses mapped via TokenWithLogo.fromToken.
Bridging Enablement
apps/cowswap-frontend/src/common/updaters/BridgingEnabledUpdater.ts
Removed feature-flag dependency; bridging enablement now derives from wallet compatibility and SWAP route. Updated effect dependencies to include computed eligibility.
Bridging SDK & Providers
apps/cowswap-frontend/src/tradingSdk/bridgingSdk.ts, apps/cowswap-frontend/src/tradingSdk/TestReceiverAccountBridgeProvider.ts
Exposed bungee/across/nearIntents providers, initialized bridgingSdk with explicit providers array, set default available provider to Bungee. TestReceiverAccountBridgeProvider now accepts EnrichedOrder (uses order.uid) and marks info.type.
Bridge Fee & Amounts
apps/cowswap-frontend/src/modules/trade/utils/getReceiveAmountInfo.ts, apps/cowswap-frontend/src/modules/trade/hooks/useGetReceiveAmountInfo.ts, libs/types/src/bridge.ts
Introduced bridgeFeeAmounts with intermediate/destination breakdown, added calculateBridgeFee helper, updated getReceiveAmountInfo signature to accept bridgeFeeAmounts and bridgeBuyAmount, and added overrideBridgeBuyAmount parameter to hook.
Bridge Quote Context
apps/cowswap-frontend/src/modules/bridge/hooks/useBridgeQuoteAmounts.ts, apps/cowswap-frontend/src/modules/bridge/hooks/useQuoteSwapContext.ts, apps/cowswap-frontend/src/modules/bridge/hooks/useQuoteBridgeContext.ts
Switched to useGetReceiveAmountInfo(true) where applicable, included bridgeFeeAmounts in returned data, and adjusted buyAmount construction using bridgeQuote amounts/min receive.
Trade State / Hooks Removed
apps/cowswap-frontend/src/modules/trade/state/receiveAmountInfoAtom.ts, apps/cowswap-frontend/src/modules/trade/hooks/useReceiveAmountInfo.ts, apps/cowswap-frontend/src/modules/trade/index.ts, apps/cowswap-frontend/src/modules/twap/state/scaledReceiveAmountInfoAtom.ts
Removed receiveAmountInfoAtom, useReceiveAmountInfo and related re-exports; logic consolidated into useGetReceiveAmountInfo. TWAP scaled atom removed.
Quote Polling Timings
apps/cowswap-frontend/src/modules/tradeQuote/services/fetchAndProcessQuote.ts, .../fetchAndProcessQuote.test.ts, apps/cowswap-frontend/src/modules/tradeQuote/hooks/usePollQuoteCallback.ts, apps/cowswap-frontend/src/modules/tradeQuote/types.ts
Added QuotePollingUpdateTimings (now + ref) tracking start timestamp; passed timings to fetchBridgingQuote; early-return guards avoid stale updates. Tests updated to pass timings.
Recipient & Proxy Handling
apps/cowswap-frontend/src/modules/accountProxy/containers/ProxyRecipient/index.tsx, apps/cowswap-frontend/src/modules/tradeQuote/hooks/useQuoteParamsRecipient.ts, apps/cowswap-frontend/src/modules/tradeQuote/hooks/useQuoteParams.ts, .../useQuoteParamsRecipient.test.ts
Added useQuoteParamsRecipient hook that derives recipient with ReceiverAccountBridgeProvider-specific rules. ProxyRecipient uses bridgeReceiverOverride and renders InfoTooltip when overridden. Tests added for recipient behavior.
Signing Steps & Flow
apps/cowswap-frontend/src/entities/trade/signingStepAtom.ts, apps/cowswap-frontend/src/modules/ethFlow/services/ethFlow/index.ts, apps/cowswap-frontend/src/modules/tradeFlow/services/swapFlow/index.ts, apps/cowswap-frontend/src/modules/trade/pure/TradeConfirmation/getPendingText.ts
Added PreparingDepositAddress signing step; flow sets this step when provider type is ReceiverAccountBridgeProvider; added display text mapping "Preparing deposit".
UI / Trade Form
apps/cowswap-frontend/src/modules/tradeFormValidation/pure/TradeFormButtons/tradeButtonsMap.tsx, apps/cowswap-frontend/src/modules/trade/containers/TradeWidget/TradeWidgetForm.tsx, apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/CurrencyInputPanel.tsx
Centralized quote error texts and added InfoTooltip for NO_INTERMEDIATE_TOKENS. TradeWidgetForm hides receive amounts when provider is ReceiverAccountBridgeProvider via new hideReceiveAmounts prop.
Trade Rate / High Fee
apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/TradeRateDetails/index.tsx, .../HighFeeWarning/hooks/useHighFeeWarning.ts
Updated to use useGetReceiveAmountInfo(true). Bridge fee percentage now computed from bridgeFeeAmounts.amountInIntermediateCurrency with decimal-aware helper.
Executed Summary & Tests
apps/cowswap-frontend/src/utils/getExecutedSummaryData.ts, apps/cowswap-frontend/src/utils/__tests__/getExecutedSummaryData.test.ts
Surplus handling now uses FractionUtils.adjustDecimalsAtoms to align decimals; introduced DisplayTokenDetails and updated tests to validate cross-decimal scenarios.
Fraction Utils & Types
libs/common-utils/src/fractionUtils.ts, libs/types/src/bridge.ts
FractionUtils.adjustDecimalsAtoms gained overloads/generic typing; BridgeQuoteAmounts extended with optional bridgeFeeAmounts field.
Bridge Orders Serializer
apps/cowswap-frontend/src/entities/bridgeOrders/state/bridgeOrdersStateSerializer.ts
Serialization/deserialization extended to handle bridgeFeeAmounts fields.
Misc / Explorer / Token Logos / Locales
apps/explorer/src/sdk/cowSdk.ts, apps/explorer/src/utils/getOrderBridgeProviderId.ts, libs/tokens/src/pure/TokenLogo/*, apps/cowswap-frontend/src/locales/en-US.po
Explorer adds nearIntentsBridgeProvider to known providers and adjusts exports; getOrderBridgeProviderId checks metadata.bridging?.providerId first; TokenLogo components accept optional address and render data-address; added several translation entries.
Dependencies
package.json
Updated multiple @cowprotocol/* packages to PR-678 npm aliases (cow-sdk, sdk-bridging, sdk-composable, sdk-cow-shed, sdk-ethers-v5-adapter, sdk-subgraph).

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant App as App Updaters
    participant BPU as BridgeProvidersUpdater
    participant SDK as bridgingSdk
    participant State as Bridge Providers Atom
    participant Quote as Quote Flow

    Note over App,BPU: Mount
    App->>BPU: mount BridgeProvidersUpdater
    BPU->>SDK: read feature flags
    BPU->>State: set provider Set (dappIds)
    BPU->>SDK: setAvailableProviders([dappIds])

    rect rgb(220,240,220)
    Note over User,Quote: Quote request (centralized)
    User->>Quote: request tokens/networks
    Quote->>SDK: bridgingSdk.getBuyTokens(params) / getTargetNetworks()
    SDK->>Quote: aggregated result
    Quote->>App: compute bridgeFeeAmounts (intermediate + destination)
    end

    rect rgb(240,230,220)
    Note over App: Signing step selection
    App->>App: inspect bridgeQuote.providerInfo.type
    alt ReceiverAccountBridgeProvider
        App->>App: set SigningStep.PreparingDepositAddress
    else other
        App->>App: set SigningStep.BridgingSigning
    end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Pay special attention to:
    • Bridge fee decimal alignment and new bridgeFeeAmounts usage (getReceiveAmountInfo.ts, getExecutedSummaryData.ts)
    • Quote polling timing guards to avoid race conditions (fetchAndProcessQuote.ts, usePollQuoteCallback.ts)
    • Bridging SDK/provider initialization and the BridgeProvidersUpdater interactions (bridgingSdk.ts, BridgeProvidersUpdater.ts)
    • Recipient derivation and ProxyRecipient rendering for ReceiverAccountBridgeProvider (useQuoteParamsRecipient.ts, ProxyRecipient/index.tsx)
    • Compatibility of PR-678 SDK changes (EnrichedOrder usage in TestReceiverAccountBridgeProvider)

Possibly related PRs

  • #6336 — Modifies bridgingSdk provider initialization and Across provider logic; overlaps with provider centralization and SDK changes.
  • #6354 — Adds ReceiverAccountBridgeProvider support and signing-step logic; closely related to recipient and signing-step changes here.
  • #6384 — Updates @cowprotocol/* package references to PR-based aliases; overlaps with dependency updates in this PR.

Suggested reviewers

  • alfetopito
  • elena-zh

Poem

🐰
Bridges bloom where flags once slept,
Providers lined, their dappIds kept,
Fees split gently, decimals neat,
Recipients chosen to the beat.
Code hops forward — small paws, big leap.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.29% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main changes: adding a Near bridge provider and implementing per-provider feature flags, directly matching the PR's core objectives.
Description check ✅ Passed The description is well-structured with a clear Summary section listing key changes, specific feature-flag links, and important operational notes. However, it lacks a 'To Test' section and Background details as suggested by the template.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@socket-security
Copy link

socket-security bot commented Nov 4, 2025

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn Critical
Critical CVE: npm form-data uses unsafe random function in form-data for choosing boundary

CVE: GHSA-fjxv-7rqg-78g4 form-data uses unsafe random function in form-data for choosing boundary (CRITICAL)

Affected versions: < 2.5.4; >= 3.0.0 < 3.0.4; >= 4.0.0 < 4.0.4

Patched version: 3.0.4

From: ?npm/[email protected]

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/cowswap-frontend/src/modules/bridge/hooks/useQuoteBridgeContext.ts (1)

22-29: Approve with minor consistency suggestion.

The refactored logic correctly uses beforeFee.buyAmount and properly guards against null values. The dependency array is correctly updated to include bridgeQuote.

Optional: Remove unnecessary optional chaining for consistency.

Line 27 uses optional chaining (bridgeQuote?.) after the null check on line 23 already ensures bridgeQuote is non-null. For consistency, consider removing the optional chaining:

-      bridgeQuote?.amountsAndCosts.beforeFee.buyAmount.toString(),
+      bridgeQuote.amountsAndCosts.beforeFee.buyAmount.toString(),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e79198 and 14cd4ca.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • apps/cowswap-frontend/src/modules/bridge/hooks/useQuoteBridgeContext.ts (1 hunks)
  • package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:62-67
Timestamp: 2025-09-25T08:49:32.256Z
Learning: In the cowswap-frontend codebase, when testing hooks that use multiple bridge providers, both providers are always properly mocked as complete jest.Mocked<BridgeProvider<BridgeQuoteResult>> objects with all required methods stubbed, ensuring no undefined returns that could break the hook logic.
📚 Learning: 2025-07-24T10:00:45.353Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6009
File: apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/hooks/useHighFeeWarning.ts:36-36
Timestamp: 2025-07-24T10:00:45.353Z
Learning: In the CowSwap frontend, when there's a bridgeFee present in the transaction, the isSell flag is always true for business reasons. This means bridge transactions are always structured as sell operations, which ensures consistent currency handling in fee percentage calculations.

Applied to files:

  • apps/cowswap-frontend/src/modules/bridge/hooks/useQuoteBridgeContext.ts
📚 Learning: 2025-09-25T08:49:32.256Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:62-67
Timestamp: 2025-09-25T08:49:32.256Z
Learning: In the cowswap-frontend codebase, when testing hooks that use multiple bridge providers, both providers are always properly mocked as complete jest.Mocked<BridgeProvider<BridgeQuoteResult>> objects with all required methods stubbed, ensuring no undefined returns that could break the hook logic.

Applied to files:

  • apps/cowswap-frontend/src/modules/bridge/hooks/useQuoteBridgeContext.ts
📚 Learning: 2025-10-13T19:41:31.440Z
Learnt from: limitofzero
Repo: cowprotocol/cowswap PR: 6351
File: apps/cowswap-frontend/src/modules/erc20Approve/containers/TradeApproveModal/useTradeApproveCallback.ts:87-121
Timestamp: 2025-10-13T19:41:31.440Z
Learning: In apps/cowswap-frontend/src/modules/erc20Approve, useApproveCallback returns Promise<TransactionResponse | undefined> and is distinct from useApproveCurrency, which can return Promise<TransactionReceipt | SafeMultisigTransactionResponse>. When reviewing approval flows, verify which hook is actually being used before flagging Safe wallet concerns.

Applied to files:

  • apps/cowswap-frontend/src/modules/bridge/hooks/useQuoteBridgeContext.ts
📚 Learning: 2025-09-25T08:46:43.815Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/modules/tradeQuote/services/fetchAndProcessQuote.test.ts:376-385
Timestamp: 2025-09-25T08:46:43.815Z
Learning: In fetchAndProcessQuote.ts, when bridgingSdk.getBestQuote() returns null, no loading state reset is needed because loading state management is handled through onQuoteResult() callback for results and processQuoteError() for errors. The null case is intentionally designed not to trigger any manager methods.

Applied to files:

  • apps/cowswap-frontend/src/modules/bridge/hooks/useQuoteBridgeContext.ts
🧬 Code graph analysis (1)
apps/cowswap-frontend/src/modules/bridge/hooks/useQuoteBridgeContext.ts (1)
apps/cowswap-frontend/src/modules/bridge/hooks/useBridgeQuoteAmounts.ts (1)
  • useBridgeQuoteAmounts (11-48)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Setup
  • GitHub Check: Cypress
🔇 Additional comments (1)
apps/cowswap-frontend/src/modules/bridge/hooks/useQuoteBridgeContext.ts (1)

20-20: LGTM! Explicit parameter improves clarity.

Explicitly passing true to useBridgeQuoteAmounts makes the override behavior clear and aligns with the updated bridge quote handling logic.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/cowswap-frontend/src/legacy/hooks/usePriceImpact/useFiatValuePriceImpact.ts (1)

48-59: LGTM! Computation logic is sound.

The updated signature and Fraction-based arithmetic are correct. The price impact calculation 100% - (output/input) is properly implemented.

Optional consistency suggestion: Lines 53-54 convert to a number for the zero-check. For consistency with Fraction-based arithmetic throughout the refactor, consider using FractionUtils.lte:

-  const fiatValueInputNum = +fiatValueInput.toFixed(6)
-  if (!fiatValueInputNum || fiatValueInputNum <= 0) return undefined
+  if (FractionUtils.lte(fiatValueInput, 0)) return undefined

However, the current approach using toFixed(6) is acceptable for fiat value ranges and avoids potential division-by-zero issues.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f088644 and a6ba5de.

📒 Files selected for processing (2)
  • apps/cowswap-frontend/src/legacy/hooks/usePriceImpact/useFiatValuePriceImpact.ts (2 hunks)
  • package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:62-67
Timestamp: 2025-09-25T08:49:32.256Z
Learning: In the cowswap-frontend codebase, when testing hooks that use multiple bridge providers, both providers are always properly mocked as complete jest.Mocked<BridgeProvider<BridgeQuoteResult>> objects with all required methods stubbed, ensuring no undefined returns that could break the hook logic.
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6009
File: apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/hooks/useHighFeeWarning.ts:36-36
Timestamp: 2025-07-24T10:00:45.353Z
Learning: In the CowSwap frontend, when there's a bridgeFee present in the transaction, the isSell flag is always true for business reasons. This means bridge transactions are always structured as sell operations, which ensures consistent currency handling in fee percentage calculations.
📚 Learning: 2025-07-24T16:42:53.154Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6009
File: apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/HighFeeWarningTooltipContent.tsx:23-33
Timestamp: 2025-07-24T16:42:53.154Z
Learning: In apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/HighFeeWarningTooltipContent.tsx, the use of toFixed(2) for percentage formatting in tooltip content is intentional and differs from the banner message formatting that uses toSignificant(2, undefined, Rounding.ROUND_DOWN). This formatting difference serves different UX purposes and should not be flagged as inconsistent.

Applied to files:

  • apps/cowswap-frontend/src/legacy/hooks/usePriceImpact/useFiatValuePriceImpact.ts
📚 Learning: 2025-10-10T20:28:16.565Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6347
File: apps/cowswap-frontend/src/modules/trade/pure/TradeConfirmation/index.tsx:49-49
Timestamp: 2025-10-10T20:28:16.565Z
Learning: In apps/cowswap-frontend/src/modules/trade, TradeConfirmation follows a two-layer architecture: TradeConfirmationView (pure/stateless) in pure/TradeConfirmation/index.tsx renders the UI, while TradeConfirmation (container) in containers/TradeConfirmation/index.tsx wraps it to freeze props during pending trades (via useStableTradeConfirmationProps), wire in signing state (useSigningStep), and inject trade confirmation state (useTradeConfirmState). Consuming modules should import the container TradeConfirmation from 'modules/trade' to preserve this stateful behavior.
<!-- [add_learning]
When reviewing component refactoring in apps/cowswap-frontend/src/modules/trade, recognize the pattern where a pure view component (e.g., TradeConfirmationView) is separated from a stateful container (e.g., TradeConfirmation) that wraps it. The container adds runtime state management (prop stabilization, signing state, etc.) while the view remains testable and composable. Do not flag usages that import th...

Applied to files:

  • apps/cowswap-frontend/src/legacy/hooks/usePriceImpact/useFiatValuePriceImpact.ts
📚 Learning: 2025-07-24T16:43:47.639Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6009
File: apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/highFeeWarningHelpers.ts:18-20
Timestamp: 2025-07-24T16:43:47.639Z
Learning: In apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/highFeeWarningHelpers.ts, the formatFeePercentage function uses ROUND_DOWN with toSignificant(2) for "at least X%" messaging. This ensures the displayed percentage is never higher than the actual fee, making the "at least" phrasing accurate. For example, if the actual fee is 25.4%, displaying "at least 25%" is correct, but "at least 26%" would be misleading.

Applied to files:

  • apps/cowswap-frontend/src/legacy/hooks/usePriceImpact/useFiatValuePriceImpact.ts
📚 Learning: 2025-10-13T19:41:31.440Z
Learnt from: limitofzero
Repo: cowprotocol/cowswap PR: 6351
File: apps/cowswap-frontend/src/modules/erc20Approve/containers/TradeApproveModal/useTradeApproveCallback.ts:87-121
Timestamp: 2025-10-13T19:41:31.440Z
Learning: In apps/cowswap-frontend/src/modules/erc20Approve, useApproveCallback returns Promise<TransactionResponse | undefined> and is distinct from useApproveCurrency, which can return Promise<TransactionReceipt | SafeMultisigTransactionResponse>. When reviewing approval flows, verify which hook is actually being used before flagging Safe wallet concerns.

Applied to files:

  • apps/cowswap-frontend/src/legacy/hooks/usePriceImpact/useFiatValuePriceImpact.ts
🧬 Code graph analysis (1)
apps/cowswap-frontend/src/legacy/hooks/usePriceImpact/useFiatValuePriceImpact.ts (1)
libs/common-utils/src/fractionUtils.ts (1)
  • FractionUtils (11-186)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cypress
🔇 Additional comments (2)
apps/cowswap-frontend/src/legacy/hooks/usePriceImpact/useFiatValuePriceImpact.ts (2)

5-6: LGTM! Import updates align with Fraction-based refactoring.

The addition of FractionUtils and the shift from Currency/CurrencyAmount to Fraction/Percent correctly supports the type changes throughout this file.


39-42: LGTM! Conversion logic correctly prepares Fraction inputs.

The conditional conversion using FractionUtils.fractionLikeToFraction properly handles the type transformation from FractionLike to Fraction, with appropriate null-handling for the updated function signature.

Copy link
Contributor

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving the PR with some issues that need to be addressed after the launch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants