Skip to content

Conversation

@shoom3301
Copy link
Contributor

@shoom3301 shoom3301 commented Nov 6, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for Near Intents bridge provider
    • Introduced app data version 1.9.0 with enhanced metadata versioning for UTM, hooks, signer, and widget data
  • Bug Fixes

    • Removed support for LINEA and PLASMA networks across the SDK
  • Chores

    • Updated bridging provider infrastructure and dependencies
    • Restructured provider management for improved multi-provider quote handling

…AIN_TO_NATIVE_WRAPPED_TOKEN_ADDRESS to support wrapped assets, changes an import and rm the sending of native tokens within getUnsignedBridgeCall
…ithin getSignedHook and implements getBridgingParams
…ment and a remove a useless check within getBridgingParams
…ithin getSignedHook, fixes getTokenByAddressAndChainId and getIntermediateTokens
…ridgeCallWithoutHooks within NearIntentsBridgeProvider
…m getUnsignedBridgeCall in favour of the balance of the sell token within the cowshed account at the swap time
…irect transfer to near deposit address within NearIntentsBridgeProvider
…col/one-click-sdk-typescript within dependencies
…TS_BLOCKCHAIN_TO_NATIVE_WRAPPED_TOKEN_ADDRESS into WRAPPED_NATIVE_CURRENCIES
allemanfredi and others added 22 commits November 3, 2025 06:31
* fix: flashloan fee calculation now matches aave's

* fix: pr comments

* fix: implement ceil rounding for flash loan fee calculations (#623)

- Fixed calculateFlashLoanAmounts to use ceil rounding (round up on any remainder)
- This ensures flash loan fees are never undercharged due to truncation
- Removed incorrect 100x scaling that was using BASIS_POINTS_SCALE
- Now using Aave's PERCENT_SCALE (10000) directly where 100% = 10000 bps
- Added 7 comprehensive unit tests covering edge cases:
  - Very small amounts (1 wei)
  - Exact division with no remainder
  - Small remainders
  - Medium DeFi amounts (ETH scale)
  - Large amounts (100+ ETH)
  - Maximum uint256-like amounts
  - Fractional percentages with remainders
- All 99 tests passing

* add opt-out flag for quote adjustments in getOrderToSign (#624)

* feat: add opt-out flag for quote adjustments in getOrderToSign

* override order to sign from params (#626)

* use applyQuote boolean instead of overriding orderToSign (#628)

* fix: pr review

---------

Co-authored-by: Martin Grabina <[email protected]>

* fix: lint

* fix: more pipeline fixes

---------

Co-authored-by: Martin Grabina <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…bstance-labs-feat/near-intents

# Conflicts:
#	.release-please-manifest.json
#	packages/flash-loans/CHANGELOG.md
#	packages/flash-loans/package.json
…ents-fixes

fix: fix bridging providerId detection
…ents-fixes

feat(bridging): use multiple providers for tokens and networks
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

📥 Commits

Reviewing files that changed from the base of the PR and between 7cc2fd0 and cdfc30a.

⛔ Files ignored due to path filters (6)
  • packages/bridging/src/providers/near-intents/near-intents-logo.png is excluded by !**/*.png
  • packages/config/src/chains/images/linea-logo-dark.svg is excluded by !**/*.svg
  • packages/config/src/chains/images/linea-logo-light.svg is excluded by !**/*.svg
  • packages/config/src/chains/images/plasma-logo.svg is excluded by !**/*.svg
  • packages/contracts-ts/src/generated/packageVersion.ts is excluded by !**/generated/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (53)
  • examples/react/wagmi/package.json (1 hunks)
  • examples/react/wagmi/src/tokens.ts (0 hunks)
  • packages/app-data/src/generatedTypes/index.ts (3 hunks)
  • packages/app-data/src/generatedTypes/latest.ts (1 hunks)
  • packages/app-data/src/generatedTypes/v1.9.0.ts (1 hunks)
  • packages/app-data/src/schemas/bridging/v0.2.0.json (1 hunks)
  • packages/app-data/src/schemas/definitions.json (1 hunks)
  • packages/app-data/src/schemas/v1.9.0.json (1 hunks)
  • packages/app-data/test/flashloan-v1.7.0.spec.ts (0 hunks)
  • packages/bridging/README.md (9 hunks)
  • packages/bridging/jest.config.ts (1 hunks)
  • packages/bridging/package.json (1 hunks)
  • packages/bridging/src/BridgingSdk/BridgingSdk.test.ts (3 hunks)
  • packages/bridging/src/BridgingSdk/BridgingSdk.ts (11 hunks)
  • packages/bridging/src/BridgingSdk/findBridgeProviderFromHook.ts (1 hunks)
  • packages/bridging/src/BridgingSdk/getCrossChainOrder.ts (1 hunks)
  • packages/bridging/src/BridgingSdk/getIntermediateSwapResult.ts (1 hunks)
  • packages/bridging/src/BridgingSdk/strategies/BestQuoteStrategy.test.ts (16 hunks)
  • packages/bridging/src/BridgingSdk/strategies/BestQuoteStrategy.ts (5 hunks)
  • packages/bridging/src/BridgingSdk/strategies/MultiQuoteStrategy.test.ts (17 hunks)
  • packages/bridging/src/BridgingSdk/strategies/MultiQuoteStrategy.ts (5 hunks)
  • packages/bridging/src/BridgingSdk/strategies/QuoteStrategy.ts (3 hunks)
  • packages/bridging/src/BridgingSdk/strategies/SingleQuoteStrategy.test.ts (5 hunks)
  • packages/bridging/src/BridgingSdk/strategies/SingleQuoteStrategy.ts (2 hunks)
  • packages/bridging/src/BridgingSdk/utils.ts (3 hunks)
  • packages/bridging/src/README.md (0 hunks)
  • packages/bridging/src/index.ts (1 hunks)
  • packages/bridging/src/providers/across/AcrossBridgeProvider.ts (2 hunks)
  • packages/bridging/src/providers/across/const/contracts.ts (0 hunks)
  • packages/bridging/src/providers/across/const/interfaces.ts (1 hunks)
  • packages/bridging/src/providers/bungee/BungeeBridgeProvider.ts (2 hunks)
  • packages/bridging/src/providers/bungee/const/contracts.ts (0 hunks)
  • packages/bridging/src/providers/mock/BaseMockBridgeProvider.ts (2 hunks)
  • packages/bridging/src/providers/near-intents/NearIntentsApi.ts (1 hunks)
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.test.ts (1 hunks)
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts (1 hunks)
  • packages/bridging/src/providers/near-intents/const/index.ts (1 hunks)
  • packages/bridging/src/providers/near-intents/util.test.ts (1 hunks)
  • packages/bridging/src/providers/near-intents/util.ts (1 hunks)
  • packages/bridging/src/test/getWallet.test.ts (1 hunks)
  • packages/bridging/src/test/getWallet.ts (0 hunks)
  • packages/bridging/src/types.ts (2 hunks)
  • packages/bridging/src/utils.ts (1 hunks)
  • packages/config/src/chains/const/chainIds.ts (0 hunks)
  • packages/config/src/chains/details/linea.ts (0 hunks)
  • packages/config/src/chains/details/plasma.ts (0 hunks)
  • packages/config/src/chains/index.ts (0 hunks)
  • packages/config/src/chains/types.ts (0 hunks)
  • packages/config/src/constants/tokens.ts (0 hunks)
  • packages/order-book/src/api.ts (1 hunks)
  • packages/sdk/README.md (0 hunks)
  • packages/subgraph/src/api.spec.ts (0 hunks)
  • packages/subgraph/src/api.ts (1 hunks)
 ___________________________________________
< Sending Skynet back to the drawing board. >
 -------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch substance-labs-feat/near-intents-1

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 6, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​wagmi/​cli@​2.5.1 ⏵ 2.7.197 +110078 +397 +1100
Updated@​types/​react@​18.3.24 ⏵ 18.3.2610010079 +196 +2100

View full report

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

📦 GitHub Packages Published

Last updated: Nov 6, 2025, 02:20:06 PM UTC

The following packages have been published to GitHub Packages with pre-release version pr-653-dd42740f:


Installation

These packages require authentication to install from GitHub Packages. First, create a .npmrc file:

# Create .npmrc file in your project root
echo "@cowprotocol:registry=https://npm.pkg.github.com" > .npmrc
echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN" >> .npmrc

To get your GitHub token:

  1. Go to https://github.com/settings/tokens
  2. Click "Generate new token (classic)"
  3. Check only the "read:packages" scope
  4. Copy the token and replace YOUR_GITHUB_TOKEN in the .npmrc file

Then install any of the packages above, either by exact version (i.e. @cowprotocol/[email protected]) or more conveniently by using the tag (@cowprotocol/cow-sdk@pr-653):

# Yarn
yarn add npm:@cowprotocol/cow-sdk@pr-653

# pnpm
pnpm install npm:@cowprotocol/cow-sdk@pr-653

# NPM
npm install npm:@cowprotocol/cow-sdk@pr-653

Update to the latest version (only if you used the tag)

Every commit will publish a new package. To upgrade to the latest version, run:

# Yarn
yarn upgrade @cowprotocol/cow-sdk

# pnpm
pnpm update @cowprotocol/cow-sdk

# NPM
npm update @cowprotocol/cow-sdk

View Packages

You can view the published packages at: https://github.com/cowprotocol/cow-sdk/packages

@shoom3301 shoom3301 closed this Nov 6, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 2025
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: 3

🧹 Nitpick comments (2)
packages/bridging/src/providers/near-intents/NearIntentsApi.ts (1)

11-18: Avoid duplicate token fetches under concurrent load.
If two callers hit getTokens() before the first response arrives, we’ll issue two upstream requests because the cache fills only after the first resolves. Hoisting the in-flight promise prevents redundant network calls and keeps rate limits happier.

   private cachedTokens: TokenResponse[] = []
+  private tokensPromise?: Promise<TokenResponse[]>
 
   async getTokens(): Promise<TokenResponse[]> {
     if (this.cachedTokens.length === 0) {
-      const response = await OneClickService.getTokens()
-      this.cachedTokens = response
+      const tokensPromise =
+        this.tokensPromise ??
+        (this.tokensPromise = OneClickService.getTokens()
+          .then((tokens) => {
+            this.cachedTokens = tokens
+            return tokens
+          })
+          .finally(() => {
+            this.tokensPromise = undefined
+          }))
+      return tokensPromise
     }
     return this.cachedTokens
   }
packages/bridging/src/BridgingSdk/strategies/BestQuoteStrategy.ts (1)

72-74: Pass the filtered provider list to the timeout helper.
executeProviderQuotes logs/labels using the list it receives; giving it the already-filtered providers keeps diagnostics aligned with the actual work.

-    await executeProviderQuotes(promises, totalTimeout, providers)
+    await executeProviderQuotes(promises, totalTimeout, providersToQuery)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7cc2fd0 and cdfc30a.

⛔ Files ignored due to path filters (6)
  • packages/bridging/src/providers/near-intents/near-intents-logo.png is excluded by !**/*.png
  • packages/config/src/chains/images/linea-logo-dark.svg is excluded by !**/*.svg
  • packages/config/src/chains/images/linea-logo-light.svg is excluded by !**/*.svg
  • packages/config/src/chains/images/plasma-logo.svg is excluded by !**/*.svg
  • packages/contracts-ts/src/generated/packageVersion.ts is excluded by !**/generated/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (53)
  • examples/react/wagmi/package.json (1 hunks)
  • examples/react/wagmi/src/tokens.ts (0 hunks)
  • packages/app-data/src/generatedTypes/index.ts (3 hunks)
  • packages/app-data/src/generatedTypes/latest.ts (1 hunks)
  • packages/app-data/src/generatedTypes/v1.9.0.ts (1 hunks)
  • packages/app-data/src/schemas/bridging/v0.2.0.json (1 hunks)
  • packages/app-data/src/schemas/definitions.json (1 hunks)
  • packages/app-data/src/schemas/v1.9.0.json (1 hunks)
  • packages/app-data/test/flashloan-v1.7.0.spec.ts (0 hunks)
  • packages/bridging/README.md (9 hunks)
  • packages/bridging/jest.config.ts (1 hunks)
  • packages/bridging/package.json (1 hunks)
  • packages/bridging/src/BridgingSdk/BridgingSdk.test.ts (3 hunks)
  • packages/bridging/src/BridgingSdk/BridgingSdk.ts (11 hunks)
  • packages/bridging/src/BridgingSdk/findBridgeProviderFromHook.ts (1 hunks)
  • packages/bridging/src/BridgingSdk/getCrossChainOrder.ts (1 hunks)
  • packages/bridging/src/BridgingSdk/getIntermediateSwapResult.ts (1 hunks)
  • packages/bridging/src/BridgingSdk/strategies/BestQuoteStrategy.test.ts (16 hunks)
  • packages/bridging/src/BridgingSdk/strategies/BestQuoteStrategy.ts (5 hunks)
  • packages/bridging/src/BridgingSdk/strategies/MultiQuoteStrategy.test.ts (17 hunks)
  • packages/bridging/src/BridgingSdk/strategies/MultiQuoteStrategy.ts (5 hunks)
  • packages/bridging/src/BridgingSdk/strategies/QuoteStrategy.ts (3 hunks)
  • packages/bridging/src/BridgingSdk/strategies/SingleQuoteStrategy.test.ts (5 hunks)
  • packages/bridging/src/BridgingSdk/strategies/SingleQuoteStrategy.ts (2 hunks)
  • packages/bridging/src/BridgingSdk/utils.ts (3 hunks)
  • packages/bridging/src/README.md (0 hunks)
  • packages/bridging/src/index.ts (1 hunks)
  • packages/bridging/src/providers/across/AcrossBridgeProvider.ts (2 hunks)
  • packages/bridging/src/providers/across/const/contracts.ts (0 hunks)
  • packages/bridging/src/providers/across/const/interfaces.ts (1 hunks)
  • packages/bridging/src/providers/bungee/BungeeBridgeProvider.ts (2 hunks)
  • packages/bridging/src/providers/bungee/const/contracts.ts (0 hunks)
  • packages/bridging/src/providers/mock/BaseMockBridgeProvider.ts (2 hunks)
  • packages/bridging/src/providers/near-intents/NearIntentsApi.ts (1 hunks)
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.test.ts (1 hunks)
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts (1 hunks)
  • packages/bridging/src/providers/near-intents/const/index.ts (1 hunks)
  • packages/bridging/src/providers/near-intents/util.test.ts (1 hunks)
  • packages/bridging/src/providers/near-intents/util.ts (1 hunks)
  • packages/bridging/src/test/getWallet.test.ts (1 hunks)
  • packages/bridging/src/test/getWallet.ts (0 hunks)
  • packages/bridging/src/types.ts (2 hunks)
  • packages/bridging/src/utils.ts (1 hunks)
  • packages/config/src/chains/const/chainIds.ts (0 hunks)
  • packages/config/src/chains/details/linea.ts (0 hunks)
  • packages/config/src/chains/details/plasma.ts (0 hunks)
  • packages/config/src/chains/index.ts (0 hunks)
  • packages/config/src/chains/types.ts (0 hunks)
  • packages/config/src/constants/tokens.ts (0 hunks)
  • packages/order-book/src/api.ts (1 hunks)
  • packages/sdk/README.md (0 hunks)
  • packages/subgraph/src/api.spec.ts (0 hunks)
  • packages/subgraph/src/api.ts (1 hunks)
💤 Files with no reviewable changes (14)
  • packages/config/src/chains/index.ts
  • packages/config/src/chains/details/plasma.ts
  • packages/subgraph/src/api.spec.ts
  • packages/bridging/src/providers/bungee/const/contracts.ts
  • packages/bridging/src/providers/across/const/contracts.ts
  • packages/bridging/src/README.md
  • packages/config/src/chains/const/chainIds.ts
  • packages/config/src/chains/types.ts
  • packages/app-data/test/flashloan-v1.7.0.spec.ts
  • packages/config/src/constants/tokens.ts
  • examples/react/wagmi/src/tokens.ts
  • packages/config/src/chains/details/linea.ts
  • packages/sdk/README.md
  • packages/bridging/src/test/getWallet.ts
🧰 Additional context used
🧠 Learnings (15)
📓 Common learnings
Learnt from: anxolin
Repo: cowprotocol/cow-sdk PR: 267
File: src/bridging/BridgingSdk/getCrossChainOrder.ts:44-46
Timestamp: 2025-04-14T20:37:56.543Z
Learning: The decoding of bridge appData (using provider.decodeBridgeHook) in the getCrossChainOrder function was intentionally left as a TODO comment for implementation in a future PR.
📚 Learning: 2025-06-10T03:06:46.146Z
Learnt from: jeffersonBastos
Repo: cowprotocol/cow-sdk PR: 327
File: packages/app-data/src/schemas/v0.3.0.json:1-10
Timestamp: 2025-06-10T03:06:46.146Z
Learning: Schema versions v0.1.0 through v0.7.0 in the app-data package are intentionally designed to allow additional properties (no "additionalProperties": false constraint), while versions v0.8.0 and later enforce strict validation. This represents a deliberate design evolution and historical schema versions should not be modified to add stricter validation.

Applied to files:

  • packages/app-data/src/schemas/definitions.json
  • packages/app-data/src/schemas/bridging/v0.2.0.json
  • packages/app-data/src/schemas/v1.9.0.json
  • packages/app-data/src/generatedTypes/index.ts
  • packages/app-data/src/generatedTypes/v1.9.0.ts
📚 Learning: 2025-05-30T05:56:12.625Z
Learnt from: shoom3301
Repo: cowprotocol/cow-sdk PR: 324
File: src/bridging/types.ts:384-385
Timestamp: 2025-05-30T05:56:12.625Z
Learning: The BridgingDepositParams interface in src/bridging/types.ts includes a bridgingId: string field along with other deposit parameters like inputTokenAddress, outputTokenAddress, inputAmount, outputAmount, owner, quoteTimestamp, fillDeadline, recipient, sourceChainId, and destinationChainId.

Applied to files:

  • packages/bridging/src/providers/mock/BaseMockBridgeProvider.ts
  • packages/bridging/src/types.ts
  • packages/bridging/src/BridgingSdk/getIntermediateSwapResult.ts
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts
  • packages/app-data/src/schemas/bridging/v0.2.0.json
  • packages/bridging/src/providers/bungee/BungeeBridgeProvider.ts
  • packages/bridging/src/providers/across/AcrossBridgeProvider.ts
  • packages/bridging/src/BridgingSdk/utils.ts
  • packages/bridging/src/BridgingSdk/getCrossChainOrder.ts
  • packages/bridging/src/BridgingSdk/BridgingSdk.ts
📚 Learning: 2025-04-14T20:37:56.543Z
Learnt from: anxolin
Repo: cowprotocol/cow-sdk PR: 267
File: src/bridging/BridgingSdk/getCrossChainOrder.ts:44-46
Timestamp: 2025-04-14T20:37:56.543Z
Learning: The decoding of bridge appData (using provider.decodeBridgeHook) in the getCrossChainOrder function was intentionally left as a TODO comment for implementation in a future PR.

Applied to files:

  • packages/bridging/src/providers/mock/BaseMockBridgeProvider.ts
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.test.ts
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts
  • packages/bridging/src/providers/bungee/BungeeBridgeProvider.ts
  • packages/bridging/src/providers/across/AcrossBridgeProvider.ts
  • packages/bridging/src/BridgingSdk/findBridgeProviderFromHook.ts
  • packages/bridging/src/BridgingSdk/getCrossChainOrder.ts
  • packages/app-data/src/generatedTypes/v1.9.0.ts
  • packages/bridging/src/BridgingSdk/BridgingSdk.ts
📚 Learning: 2025-11-06T11:26:21.321Z
Learnt from: shoom3301
Repo: cowprotocol/cow-sdk PR: 642
File: packages/bridging/src/BridgingSdk/BridgingSdk.ts:124-144
Timestamp: 2025-11-06T11:26:21.321Z
Learning: In the cow-sdk bridging module (packages/bridging/), all bridge providers return ChainInfo objects that are singleton instances imported from cowprotocol/sdk-config. The chain objects (mainnet, arbitrumOne, base, optimism, polygon, avalanche, gnosisChain, etc.) are exported as constants from packages/config/src/chains/details/ and are shared across all providers. This singleton pattern makes object reference comparison (e.g., with Array.includes()) safe for deduplicating networks returned by multiple providers, as the same chain will always be represented by the same object reference.
<!--

Applied to files:

  • packages/bridging/src/providers/mock/BaseMockBridgeProvider.ts
  • packages/bridging/src/test/getWallet.test.ts
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.test.ts
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts
  • packages/bridging/src/providers/bungee/BungeeBridgeProvider.ts
  • packages/subgraph/src/api.ts
  • packages/bridging/src/providers/across/AcrossBridgeProvider.ts
  • packages/order-book/src/api.ts
  • packages/bridging/src/BridgingSdk/findBridgeProviderFromHook.ts
  • packages/bridging/README.md
  • packages/bridging/src/providers/near-intents/const/index.ts
  • packages/bridging/src/BridgingSdk/strategies/BestQuoteStrategy.ts
  • packages/bridging/src/BridgingSdk/utils.ts
  • packages/bridging/src/BridgingSdk/strategies/SingleQuoteStrategy.ts
  • packages/bridging/src/BridgingSdk/strategies/MultiQuoteStrategy.ts
  • packages/bridging/src/BridgingSdk/BridgingSdk.ts
📚 Learning: 2025-08-12T09:15:28.459Z
Learnt from: alfetopito
Repo: cowprotocol/cow-sdk PR: 391
File: src/trading/getEthFlowTransaction.ts:80-85
Timestamp: 2025-08-12T09:15:28.459Z
Learning: In the CoW SDK codebase, ETH_FLOW_ADDRESSES and BARN_ETH_FLOW_ADDRESSES are typed as Record<SupportedChainId, string>, which requires all SupportedChainId enum values to have corresponding string entries. TypeScript compilation will fail if any chainId is missing from these mappings, making runtime guards for missing addresses unnecessary in these specific cases.

Applied to files:

  • packages/bridging/src/test/getWallet.test.ts
  • packages/bridging/src/providers/across/AcrossBridgeProvider.ts
  • packages/order-book/src/api.ts
  • packages/bridging/src/providers/across/const/interfaces.ts
  • packages/bridging/src/providers/near-intents/const/index.ts
📚 Learning: 2025-03-21T15:14:59.767Z
Learnt from: anxolin
Repo: cowprotocol/cow-sdk PR: 251
File: src/bridging/providers/across/AcrossApi.ts:5-10
Timestamp: 2025-03-21T15:14:59.767Z
Learning: In AcrossApi.ts, interfaces like AvailableRoutesRequest and Route use string types for chain IDs (originChainId, destinationChainId) because they're mapping to an external API contract from Across, which expects chain IDs as strings, rather than using internal enum types like TargetChainId.

Applied to files:

  • packages/bridging/src/test/getWallet.test.ts
  • packages/bridging/src/providers/across/AcrossBridgeProvider.ts
  • packages/order-book/src/api.ts
  • packages/bridging/src/BridgingSdk/getCrossChainOrder.ts
📚 Learning: 2025-06-09T23:25:56.909Z
Learnt from: jeffersonBastos
Repo: cowprotocol/cow-sdk PR: 327
File: packages/app-data/src/schemas/quote/v1.0.0.json:2-2
Timestamp: 2025-06-09T23:25:56.909Z
Learning: In the CoW Protocol app-data schemas, the $id field in JSON schema files doesn't always match the filename version. When schema versions maintain the same fundamental structure, they preserve the same $id as the version that introduced that structure for compatibility purposes. For example, quote schemas v0.3.0, v1.0.0, and v1.1.0 all reference "#quote/v0.2.0.json" in their $id field because they maintain the same core structure as v0.2.0.

Applied to files:

  • packages/app-data/src/schemas/bridging/v0.2.0.json
  • packages/app-data/src/schemas/v1.9.0.json
📚 Learning: 2025-06-10T03:06:53.585Z
Learnt from: jeffersonBastos
Repo: cowprotocol/cow-sdk PR: 327
File: packages/app-data/src/schemas/v0.2.0.json:34-39
Timestamp: 2025-06-10T03:06:53.585Z
Learning: In the CoW Protocol app-data schemas, nested schema references are intentionally kept at stable versions (like v0.1.0) even when the root schema version increases, to maintain backward compatibility when the referenced schemas have breaking changes.

Applied to files:

  • packages/app-data/src/schemas/bridging/v0.2.0.json
  • packages/app-data/src/generatedTypes/latest.ts
  • packages/app-data/src/schemas/v1.9.0.json
  • packages/app-data/src/generatedTypes/index.ts
📚 Learning: 2025-06-10T02:39:24.134Z
Learnt from: jeffersonBastos
Repo: cowprotocol/cow-sdk PR: 327
File: packages/app-data/src/schemas/v1.1.0.json:10-14
Timestamp: 2025-06-10T02:39:24.134Z
Learning: In the CoW Protocol app-data schemas, v1.0.0.json and v1.1.0.json both intentionally use default version "0.11.0" rather than matching their filenames. This is a deliberate versioning design, not an error.

Applied to files:

  • packages/app-data/src/generatedTypes/latest.ts
  • packages/app-data/src/schemas/v1.9.0.json
  • packages/app-data/src/generatedTypes/index.ts
📚 Learning: 2025-06-10T03:06:45.755Z
Learnt from: jeffersonBastos
Repo: cowprotocol/cow-sdk PR: 327
File: packages/app-data/src/schemas/hooks/v0.2.0.json:14-14
Timestamp: 2025-06-10T03:06:45.755Z
Learning: In the CoW Protocol app-data schemas, there are two different version concepts: the schema version (indicated by the filename like v0.2.0.json) represents the schema structure/capability version, while the default version field represents the content/data version for backward compatibility. When new schema versions add optional fields, the default version can remain the same to ensure existing implementations don't break.

Applied to files:

  • packages/app-data/src/generatedTypes/latest.ts
  • packages/app-data/src/schemas/v1.9.0.json
  • packages/app-data/src/generatedTypes/index.ts
📚 Learning: 2025-03-21T15:14:34.969Z
Learnt from: anxolin
Repo: cowprotocol/cow-sdk PR: 251
File: src/bridging/providers/across/AcrossApi.ts:21-69
Timestamp: 2025-03-21T15:14:34.969Z
Learning: In the Across provider implementation, naming conventions that match the external Across API are intentionally preserved within internal implementation code, even if they appear inconsistent. These naming conventions are not exposed outside the provider implementation.

Applied to files:

  • packages/bridging/src/providers/across/AcrossBridgeProvider.ts
📚 Learning: 2025-06-10T02:48:05.886Z
Learnt from: jeffersonBastos
Repo: cowprotocol/cow-sdk PR: 327
File: packages/app-data/src/api/fetchDocFromAppData.ts:16-21
Timestamp: 2025-06-10T02:48:05.886Z
Learning: In the CoW Protocol SDK, when migrating code from the original package, the team prefers to maintain consistency with the original implementation even when static analysis tools suggest changes like replacing void with undefined in union types.

Applied to files:

  • packages/order-book/src/api.ts
  • packages/bridging/src/BridgingSdk/findBridgeProviderFromHook.ts
  • packages/bridging/src/providers/across/const/interfaces.ts
  • packages/bridging/package.json
  • packages/bridging/src/BridgingSdk/strategies/QuoteStrategy.ts
  • examples/react/wagmi/package.json
📚 Learning: 2025-09-16T07:22:55.962Z
Learnt from: shoom3301
Repo: cowprotocol/cow-sdk PR: 498
File: packages/sdk/README.md:143-177
Timestamp: 2025-09-16T07:22:55.962Z
Learning: In the CoW Protocol SDK v7 migration guide, the wagmi integration example requires type casting (`as unknown as ViemAdapterOptions`) when creating a ViemAdapter with wagmi's usePublicClient() and useWalletClient() hooks because wagmi's returned types are not directly compatible with ViemAdapterOptions despite being structurally similar. This casting is necessary and used throughout the codebase for similar type compatibility issues.

Applied to files:

  • examples/react/wagmi/package.json
📚 Learning: 2025-09-16T07:22:55.962Z
Learnt from: shoom3301
Repo: cowprotocol/cow-sdk PR: 498
File: packages/sdk/README.md:143-177
Timestamp: 2025-09-16T07:22:55.962Z
Learning: In the CoW Protocol SDK v7 migration guide, the wagmi integration example requires type casting (`as unknown as ViemAdapterOptions`) when creating a ViemAdapter with wagmi's usePublicClient() and useWalletClient() hooks because wagmi's returned types are not directly compatible with ViemAdapterOptions despite being structurally similar.

Applied to files:

  • examples/react/wagmi/package.json
🧬 Code graph analysis (17)
packages/bridging/src/providers/mock/BaseMockBridgeProvider.ts (1)
packages/order-book/src/types.ts (1)
  • EnrichedOrder (6-8)
packages/bridging/src/types.ts (2)
packages/config/src/chains/types.ts (1)
  • ChainId (41-41)
packages/order-book/src/types.ts (1)
  • EnrichedOrder (6-8)
packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.test.ts (6)
packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts (2)
  • NearIntentsBridgeProvider (40-276)
  • NEAR_INTENTS_HOOK_DAPP_ID (29-29)
packages/bridging/src/providers/near-intents/NearIntentsApi.ts (1)
  • NearIntentsApi (10-28)
packages/common/src/adapters/context.ts (1)
  • setGlobalAdapter (37-40)
packages/bridging/src/providers/near-intents/const/index.ts (2)
  • NEAR_INTENTS_SUPPORTED_NETWORKS (9-18)
  • NEAR_INTENTS_HOOK_DAPP_ID (7-7)
packages/bridging/src/types.ts (1)
  • QuoteBridgeRequest (41-49)
packages/config/src/chains/const/contracts.ts (1)
  • ETH_ADDRESS (4-4)
packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts (10)
packages/bridging/src/providers/near-intents/const/index.ts (2)
  • NEAR_INTENTS_SUPPORTED_NETWORKS (9-18)
  • NEAR_INTENTS_STATUS_TO_COW_STATUS (33-41)
packages/bridging/src/types.ts (8)
  • BridgeQuoteResult (53-99)
  • ReceiverAccountBridgeProvider (232-243)
  • BridgeProviderInfo (16-21)
  • BuyTokensParams (132-136)
  • GetProviderBuyTokens (138-141)
  • QuoteBridgeRequest (41-49)
  • BridgingDepositParams (423-435)
  • BridgeStatusResult (114-126)
packages/cow-shed/src/CowShedSdk.ts (2)
  • CowShedSdkOptions (71-81)
  • CowShedSdk (83-181)
packages/bridging/src/providers/near-intents/NearIntentsApi.ts (1)
  • NearIntentsApi (10-28)
packages/common/src/adapters/context.ts (1)
  • setGlobalAdapter (37-40)
packages/bridging/src/providers/near-intents/util.ts (4)
  • adaptTokens (32-38)
  • getTokenByAddressAndChainId (40-52)
  • calculateDeadline (8-15)
  • adaptToken (17-30)
packages/config/src/types/tokens.ts (1)
  • TokenInfo (6-14)
packages/contracts-ts/src/index.ts (1)
  • OrderKind (19-19)
packages/config/src/chains/const/contracts.ts (1)
  • ETH_ADDRESS (4-4)
packages/config/src/types/ethereum.ts (1)
  • EvmCall (1-5)
packages/bridging/src/providers/bungee/BungeeBridgeProvider.ts (2)
packages/order-book/src/types.ts (1)
  • EnrichedOrder (6-8)
packages/bridging/src/types.ts (2)
  • BridgingDepositParams (423-435)
  • BridgeStatusResult (114-126)
packages/bridging/src/providers/across/AcrossBridgeProvider.ts (2)
packages/order-book/src/types.ts (1)
  • EnrichedOrder (6-8)
packages/bridging/src/types.ts (2)
  • BridgingDepositParams (423-435)
  • BridgeStatusResult (114-126)
packages/bridging/src/BridgingSdk/findBridgeProviderFromHook.ts (3)
packages/bridging/src/types.ts (2)
  • BridgeProvider (161-226)
  • BridgeQuoteResult (53-99)
packages/bridging/src/utils.ts (1)
  • getPostHooks (32-47)
packages/bridging/src/providers/bungee/const/misc.ts (1)
  • HOOK_DAPP_BRIDGE_PROVIDER_PREFIX (3-3)
packages/bridging/src/providers/near-intents/util.test.ts (3)
packages/bridging/src/providers/near-intents/util.ts (2)
  • adaptToken (17-30)
  • getTokenByAddressAndChainId (40-52)
packages/config/src/constants/tokens.ts (1)
  • WRAPPED_NATIVE_CURRENCIES (14-76)
packages/config/src/chains/const/contracts.ts (1)
  • ETH_ADDRESS (4-4)
packages/bridging/src/providers/near-intents/const/index.ts (8)
packages/config/src/chains/details/arbitrum.ts (1)
  • arbitrumOne (13-55)
packages/config/src/chains/details/avalanche.ts (1)
  • avalanche (9-47)
packages/config/src/chains/details/base.ts (1)
  • base (12-54)
packages/config/src/chains/details/bnb.ts (1)
  • bnb (9-53)
packages/config/src/chains/details/gnosis.ts (1)
  • gnosisChain (12-58)
packages/config/src/chains/details/mainnet.ts (1)
  • mainnet (12-55)
packages/config/src/chains/details/optimism.ts (1)
  • optimism (8-43)
packages/config/src/chains/details/polygon.ts (1)
  • polygon (8-46)
packages/bridging/src/BridgingSdk/strategies/BestQuoteStrategy.ts (2)
packages/bridging/src/types.ts (4)
  • MultiQuoteRequest (488-495)
  • DefaultBridgeProvider (515-515)
  • MultiQuoteResult (447-451)
  • BestQuoteProviderContext (510-513)
packages/trading/src/tradingSdk.ts (1)
  • TradingSdk (43-341)
packages/bridging/src/BridgingSdk/utils.ts (1)
packages/bridging/src/types.ts (1)
  • DefaultBridgeProvider (515-515)
packages/bridging/src/BridgingSdk/strategies/SingleQuoteStrategy.ts (2)
packages/trading/src/tradingSdk.ts (1)
  • TradingSdk (43-341)
packages/bridging/src/types.ts (2)
  • DefaultBridgeProvider (515-515)
  • CrossChainQuoteAndPost (319-319)
packages/bridging/src/BridgingSdk/strategies/MultiQuoteStrategy.ts (3)
packages/bridging/src/types.ts (4)
  • MultiQuoteRequest (488-495)
  • DefaultBridgeProvider (515-515)
  • MultiQuoteResult (447-451)
  • ProviderQuoteContext (505-508)
packages/trading/src/tradingSdk.ts (1)
  • TradingSdk (43-341)
packages/bridging/src/BridgingSdk/utils.ts (4)
  • validateCrossChainRequest (15-22)
  • resolveProvidersToQuery (130-148)
  • executeProviderQuotes (72-87)
  • createBridgeRequestTimeoutPromise (25-31)
packages/bridging/src/BridgingSdk/strategies/QuoteStrategy.ts (2)
packages/trading/src/tradingSdk.ts (1)
  • TradingSdk (43-341)
packages/bridging/src/types.ts (1)
  • DefaultBridgeProvider (515-515)
packages/bridging/src/providers/near-intents/util.ts (4)
packages/config/src/types/tokens.ts (1)
  • TokenInfo (6-14)
packages/bridging/src/providers/near-intents/const/index.ts (2)
  • NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS (22-31)
  • NearBlockchainKey (20-20)
packages/config/src/constants/tokens.ts (1)
  • WRAPPED_NATIVE_CURRENCIES (14-76)
packages/config/src/chains/const/contracts.ts (1)
  • ETH_ADDRESS (4-4)
packages/app-data/src/generatedTypes/index.ts (2)
packages/app-data/src/generatedTypes/v1.9.0.ts (1)
  • AppDataRootSchema (186-191)
packages/trading/src/types.ts (1)
  • AppDataRootSchema (226-226)
packages/bridging/src/BridgingSdk/BridgingSdk.ts (3)
packages/bridging/src/types.ts (3)
  • DefaultBridgeProvider (515-515)
  • BuyTokensParams (132-136)
  • GetProviderBuyTokens (138-141)
packages/config/src/chains/types.ts (1)
  • ChainInfo (77-164)
packages/config/src/types/tokens.ts (1)
  • TokenInfo (6-14)
🪛 Gitleaks (8.28.0)
packages/bridging/src/providers/near-intents/util.test.ts

[high] 110-110: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ 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). (4)
  • GitHub Check: Publish to GitHub Packages
  • GitHub Check: test
  • GitHub Check: Build Package
  • GitHub Check: eslint
🔇 Additional comments (36)
packages/bridging/package.json (3)

47-49: Clarify the ethers dependency organization.

The changes introduce direct "ethers": "^5.7.2" as a devDependency alongside existing ethers-v5 and ethers-v6 aliases. This appears redundant—the direct ethers import would resolve to v5.7.2, duplicating the ethers-v5 alias.

Verify the intent: Is the direct ethers needed for bridge provider logic, or should it be removed in favor of the explicit versioned aliases?


35-36: All new dependencies are properly imported and utilized.

Verification confirms that the three new dependencies are actively used in the bridging package:

  • @cowprotocol/sdk-weiroll: Used in the Across deposit provider
  • @defuse-protocol/one-click-sdk-typescript: Used extensively in Near Intents provider modules
  • @cowprotocol/sdk-order-signing: Used in bridge request mocks

No unused dependency concerns.


36-36: Let me verify if a stable version exists for the Defuse protocol package:

Pre-release dependency acknowledged as latest available version.

The "@defuse-protocol/one-click-sdk-typescript" package version "0.1.1-0.2" is the latest version available on npm. The package is actively used across the Near Intents bridge implementation (util.ts, NearIntentsApi.ts, NearIntentsBridgeProvider.ts, and related test files).

While this is a pre-release version that carries inherent stability considerations, no stable version is currently available. The dependency choice appears intentional for supporting the Near Intents bridge functionality. Consider documenting this early-stage dependency or tracking the Defuse protocol repository for stable releases.

packages/bridging/src/BridgingSdk/getIntermediateSwapResult.ts (1)

93-106: LGTM! Verification confirms provider.info.dappId is always defined.

The dappId property is defined as a required field in the BridgeProviderInfo interface (no optional modifier), and all provider implementations (NearIntents, Across, Bungee) initialize it. The addition of providerId to the bridging metadata is safe and aligns with the app-data v1.9.0 schema update.

packages/subgraph/src/api.ts (2)

1-3: Import reordering - no functional impact.

The reordering of imports is a minor organizational change with no functional impact.


40-50: LINEA and PLASMA references successfully removed from codebase.

Comprehensive verification confirms zero lingering references to either chain across all file types. The removal from SUBGRAPH_PROD_CONFIG is complete and consistent with the PR objectives.

packages/order-book/src/api.ts (3)

4-6: Import organization changes - no functional impact.

The addition of imports and reordering are minor organizational changes with no functional impact.

Also applies to: 12-12


41-51: LGTM - Production config correctly updated.

The removal of LINEA and PLASMA from the production configuration is consistent with the PR objectives and aligns with the enum changes in SupportedChainId.


56-66: LGTM - Staging config correctly updated.

The removal of LINEA and PLASMA from the staging configuration mirrors the production config changes and maintains consistency across environments.

packages/bridging/jest.config.ts (1)

12-12: LGTM: Formatting adjustment.

Trailing comma removed from the array—cosmetic change with no functional impact.

examples/react/wagmi/package.json (1)

12-18: LGTM: Workspace dependencies updated.

The migration to workspace:* references for CoW Protocol packages and the viem version bump to ^2.38.6 look good. Since wagmi is pinned to latest, ensure the updated viem version remains compatible with the wagmi version that gets resolved.

packages/bridging/src/test/getWallet.test.ts (2)

2-2: LGTM: Import order adjusted.

Reordering imports is cosmetic with no functional impact.


84-106: LGTM: Test coverage updated to exclude removed chains.

LINEA and PLASMA have been removed from the tested chain IDs, aligning with the broader deprecation of these chains across the codebase.

packages/bridging/src/providers/near-intents/const/index.ts (4)

1-7: LGTM: Imports and constants defined correctly.

The hook dapp ID follows the standard pattern with the bridge provider prefix.


9-18: LGTM: Supported networks array is well-defined.

The array includes all major chains supported by Near Intents. The use of singleton chain objects from @cowprotocol/sdk-config ensures consistent object references across providers.

Based on learnings.


20-31: LGTM: Blockchain key mappings are correct.

The mapping from Near's blockchain keys to chain IDs is correctly structured with proper TypeScript typing using as const satisfies Record<NearBlockchainKey, number>.


33-41: Status mapping is complete and verified.

The mapping covers all seven possible status values from the Defuse One-Click API: PENDING_DEPOSIT, KNOWN_DEPOSIT_TX, PROCESSING, SUCCESS, INCOMPLETE_DEPOSIT, REFUNDED, and FAILED. Each is explicitly mapped to an appropriate BridgeStatus value. Additionally, both lookup sites use nullish coalescing (?? / ||) operators to fall back to BridgeStatus.UNKNOWN, providing safety against any unexpected status values.

packages/app-data/src/generatedTypes/latest.ts (1)

3-3: LGTM: Latest schema version updated to v1.9.0.

The export now points to the newly introduced v1.9.0 schema module.

packages/app-data/src/schemas/definitions.json (1)

51-57: LGTM: Schema description updated to reflect broader dappId format.

The title change from "hex string" to "arbitrary string" correctly reflects that dappIds are not restricted to hexadecimal format. The validation rules remain unchanged (minLength: 1, type: string), so this is purely a documentation improvement.

packages/bridging/src/providers/mock/BaseMockBridgeProvider.ts (2)

23-23: LGTM: Import added for updated signature.

EnrichedOrder import supports the getBridgingParams signature change.


56-65: LGTM: Method signature updated to accept EnrichedOrder.

The signature change from orderUid: string to order: EnrichedOrder aligns with the broader API refactor across all bridge providers, providing richer context for bridging parameter extraction.

packages/bridging/src/utils.ts (1)

32-47: LGTM: Enhanced flexibility for app data handling.

The signature change to accept string | object improves flexibility by allowing callers to pass pre-parsed app data objects, avoiding redundant JSON parsing. The type guard ensures safe handling of both cases while maintaining backward compatibility.

packages/bridging/src/BridgingSdk/getCrossChainOrder.ts (1)

52-52: LGTM! API signature updated to pass full order object.

The change from passing order.uid to passing the full order object aligns with the broader refactor where BridgeProvider.getBridgingParams now accepts EnrichedOrder instead of a string UID. This provides providers with richer context for deriving bridging parameters.

packages/bridging/src/BridgingSdk/strategies/MultiQuoteStrategy.test.ts (1)

109-657: LGTM! Test suite updated to match new strategy API.

All test call sites have been consistently updated to pass config.tradingSdk and config.providers as separate arguments instead of the entire config object. The changes are mechanical and preserve all test coverage.

packages/bridging/src/BridgingSdk/BridgingSdk.test.ts (1)

94-94: LGTM! Public API method renamed for clarity.

The method rename from getProviders() to getAvailableProviders() better conveys that the returned list may be filtered based on runtime provider selection. All test call sites consistently updated.

packages/bridging/src/BridgingSdk/strategies/SingleQuoteStrategy.test.ts (1)

100-305: LGTM! Test suite aligned with new strategy signature.

All calls to strategy.execute have been consistently updated to pass tradingSdk and providers as separate arguments. The update includes both success and error test cases.

packages/bridging/src/index.ts (1)

17-22: LGTM! Near Intents provider added to public API.

The new provider exports follow the established pattern used by Across and Bungee providers, exporting both the provider class and its associated types.

packages/bridging/src/BridgingSdk/strategies/QuoteStrategy.ts (1)

1-23: LGTM! Strategy interface refactored for explicit dependency injection.

The abstract execute method signature now accepts tradingSdk and providers as explicit parameters instead of a BridgingSdkConfig object. This change:

  • Enables runtime provider filtering without config mutation
  • Makes dependencies explicit
  • Improves testability by reducing coupling to config structure

All concrete strategy implementations and tests have been updated accordingly.

packages/bridging/README.md (2)

135-149: LGTM! Documentation updated to reflect API changes.

The example code has been updated from sdk.* to bridgingSdk.* to align with the bridging-specific SDK instance naming throughout the codebase.


417-484: LGTM! Excellent addition of provider management documentation.

The new Provider Management section clearly documents:

  • How to retrieve active providers with getAvailableProviders()
  • How to filter providers at runtime with setAvailableProviders()
  • Practical examples including dynamic provider selection
  • Clear explanation that an empty array resets to all providers

The examples are comprehensive and demonstrate real-world usage patterns.

packages/app-data/src/schemas/bridging/v0.2.0.json (1)

23-34: I need to gather more information about blockchain address formats and other bridging providers in the codebase.

Let me check if there are other bridging providers in the codebase beyond Across:

Based on my verification, the pattern for destinationTokenAddress is appropriate and does not require changes:

Pattern verification confirms the regex is well-suited for multi-chain address formats.

The review raised three concerns, but verification shows:

  1. Underscores: Solana addresses use base58 encoding (32-44 characters), and Base58 uses numbers 1-9 and letters excluding O, I, l—no underscores. Bech32 uses a specialized Base32 alphabet and must be either all lowercase or all uppercase, excluding underscores. No major blockchain uses underscores in token addresses.

  2. Forward slashes: None of the investigated formats (EVM, Solana, Flow, Cosmos, Bitcoin) use forward slashes in address representations.

  3. 64-character limit: All documented formats fit comfortably:

    • Solana: 32-44 characters
    • Flow: 16 hex-encoded characters
    • Ethereum: 42 characters including "0x"
    • Cosmos Bech32: Varies but well under 64
    • Hedera IDs and numeric formats: Shorter than 64

The pattern correctly supports the tested examples (EVM addresses, Flow's dot-notation format, Hedera numeric IDs).

packages/bridging/src/providers/across/const/interfaces.ts (1)

11-11: Indexed owner fixes log decoding

Marking owner as indexed matches the on-chain Trade event layout so we pull the field from the correct topic again. Nice catch.

packages/bridging/src/providers/across/AcrossBridgeProvider.ts (1)

39-39: Passing the full order unlocks richer context

Thanks for switching the contract call to accept an EnrichedOrder; deriving orderUid locally keeps current behavior while giving us room to use more order fields later.

Also applies to: 201-205

packages/bridging/src/providers/near-intents/util.test.ts (1)

6-142: Great coverage for Near Intents adapters

These scenarios pin down every branch in adaptToken and getTokenByAddressAndChainId, so future regressions in chain mapping or address resolution should surface immediately.

packages/bridging/src/types.ts (1)

2-3: BridgeProvider signature refactor lines up

Importing EnrichedOrder, updating the interface, and adding DefaultBridgeProvider keeps the types coherent with the provider changes elsewhere. Looks clean.

Also applies to: 195-203, 515-515

packages/app-data/src/schemas/v1.9.0.json (1)

1-82: v1.9.0 schema wired correctly

The new root schema anchors version to 1.9.0 and pulls in the expected metadata sub-schemas with additionalProperties: false, so validation stays consistent with the generated typings.

Comment on lines +185 to +205
expect(quote).toEqual({
isSell: true,
depositAddress: '0xAd8b7139196c5ae9fb66B71C91d87A1F9071687e',
quoteTimestamp: 1756910815987,
expectedFillTimeSeconds: 49,
limits: { minDeposit: 35000000000000n, maxDeposit: 35000000000000n },
fees: { bridgeFee: 4849936143039n, destinationGasFee: 0n },
amountsAndCosts: {
beforeFee: { buyAmount: 468413404557660287n, sellAmount: 35000000000000n },
afterFee: { buyAmount: 463000005761085287n, sellAmount: 35000000000000n },
afterSlippage: { buyAmount: 463000005761085287n, sellAmount: 35000000000000n },
slippageBps: 1385,
costs: {
bridgingFee: {
feeBps: 1385,
amountInSellCurrency: 64907860018526376n,
amountInBuyCurrency: 4849936143039n,
},
},
},
})
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Bridge fee amounts are returned in the wrong currencies (and lose precision).

NearIntentsBridgeProvider.getQuote currently assigns feeAmountInBuyCurrency = Math.trunc(Number(quote.amountIn) * slippage) and feeAmountInSellCurrency = Math.trunc(Number(quote.amountOut) * slippage). That swaps the currencies—the “buy currency” value you assert here is actually denominated in the sell token—so any consumer will misreport fees. Worse, quote.amountOut is 468 413 404 557 660 287, which is well above Number.MAX_SAFE_INTEGER; converting it with Number() drops precision before the multiplication. Please keep the math in big integers (or a big-number lib) and feed each field with the correct currency, e.g.:

-    const feeAmountInBuyCurrency = Math.trunc(Number(quote.amountIn) * slippage)
-    const feeAmountInSellCurrency = Math.trunc(Number(quote.amountOut) * slippage)
-    const bridgeFee = Math.trunc(Number(quote.amountIn) * slippage)
+    const amountIn = BigInt(quote.amountIn)
+    const amountOut = BigInt(quote.amountOut)
+    const minAmountOut = BigInt(quote.minAmountOut)
+    const bridgeFee = (amountIn * BigInt(slippageBps)) / 10_000n
+    const feeAmountInSellCurrency = bridgeFee
+    const feeAmountInBuyCurrency = amountOut - minAmountOut

…and update the returned structure/tests to use those BigInt values directly. This keeps precision intact and ensures the sell/buy fee fields match their names.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.test.ts
around lines 185 to 205, the test and provider swap fee currencies and lose
precision by converting big token amounts to Number; change the provider to
compute fee amounts using BigInt arithmetic (or a bignum lib) without
Number()/Math.trunc, calculate feeAmountInSellCurrency from quote.amountIn and
feeAmountInBuyCurrency from quote.amountOut (or the inverse that matches your
domain: fee in sell currency must be derived from sell amount, fee in buy
currency from buy amount), and return those BigInt values in the response
structure; then update this test assertion to expect the corresponding BigInt
fee fields (not Number) and adjust any slippage/feeBps math to use integer math
to preserve precision.

Comment on lines +145 to +186
const payoutRatio = Number(quote.amountOutUsd) / Number(quote.amountInUsd)
const slippage = 1 - payoutRatio
const slippageBps = Math.trunc(slippage * 10_000)
const feeAmountInBuyCurrency = Math.trunc(Number(quote.amountIn) * slippage)
const feeAmountInSellCurrency = Math.trunc(Number(quote.amountOut) * slippage)
const bridgeFee = Math.trunc(Number(quote.amountIn) * slippage)

return {
isSell: request.kind === OrderKind.SELL,
depositAddress: quote.depositAddress,
quoteTimestamp: new Date(isoDate).getTime(),
expectedFillTimeSeconds: quote.timeEstimate,
limits: {
minDeposit: BigInt(quote.minAmountIn),
maxDeposit: BigInt(quote.amountIn),
},
fees: {
bridgeFee: BigInt(bridgeFee), // The bridge fee is already included in `minAmountOut`. This means `bridgeFee` represents the maximum possible fee (worst case), but the actual fee may be lower.
destinationGasFee: BigInt(0),
},
amountsAndCosts: {
beforeFee: {
sellAmount: BigInt(quote.amountIn),
buyAmount: BigInt(quote.amountOut),
},
afterFee: {
sellAmount: BigInt(quote.amountIn),
buyAmount: BigInt(quote.minAmountOut),
},
afterSlippage: {
sellAmount: BigInt(quote.amountIn),
buyAmount: BigInt(quote.minAmountOut),
},
slippageBps,
costs: {
bridgingFee: {
feeBps: slippageBps,
amountInSellCurrency: BigInt(feeAmountInSellCurrency),
amountInBuyCurrency: BigInt(feeAmountInBuyCurrency),
},
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix precision and currency math in fee breakdown

quote.amountIn/amountOut/minAmountOut come back as atomic string amounts (e.g. '1000000000000000000'). Casting them to Number and running Math.trunc drops precision once the value exceeds 2^53, so the bridgeFee/amountInSellCurrency fields we emit are rounded and wrong for normal-sized ERC‑20 amounts. On top of that, feeAmountInBuyCurrency is derived from the sell-token amount, meaning we return WETH units where consumers expect the buy-token units. Please compute the fee deltas with BigInt directly on the string values (e.g. const feeBuy = BigInt(quote.amountOut) - BigInt(quote.minAmountOut)) and only derive sell-token units from that via integer math—without ever going through Number.

🤖 Prompt for AI Agents
packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts around
lines 145-186: the code uses Number/Math.trunc on atomic string amounts which
loses precision for big ERC-20 values and computes fee amounts in the wrong
currency; replace all Number/Math.trunc usage with BigInt arithmetic on the
provided atomic strings: compute feeBuy = BigInt(quote.amountOut) -
BigInt(quote.minAmountOut), compute feeSell = (feeBuy * BigInt(quote.amountIn))
/ BigInt(quote.amountOut) (integer division), set feeAmountInBuyCurrency =
feeBuy and feeAmountInSellCurrency = feeSell, set bridgeFee = feeSell, compute
slippageBps as Number(((BigInt(quote.amountOut) - BigInt(quote.minAmountOut)) *
10000n) / BigInt(quote.amountOut)), and keep all deposit/amount fields as
BigInt(quote.*) without ever converting to Number.

Comment on lines +258 to +261
status: NEAR_INTENTS_STATUS_TO_COW_STATUS[statusResponse.status] || BridgeStatus.UNKNOWN,
depositTxHash: statusResponse.swapDetails?.originChainTxHashes[0]?.hash,
fillTxHash: statusResponse.swapDetails?.destinationChainTxHashes[0]?.hash,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Use optional chaining when indexing swap hashes

When swapDetails.originChainTxHashes (or destinationChainTxHashes) is undefined—as happens while a bridge is still pending—the expression statusResponse.swapDetails?.originChainTxHashes[0] still performs the [0] access and throws. Please guard the index as well:

-        depositTxHash: statusResponse.swapDetails?.originChainTxHashes[0]?.hash,
-        fillTxHash: statusResponse.swapDetails?.destinationChainTxHashes[0]?.hash,
+        depositTxHash: statusResponse.swapDetails?.originChainTxHashes?.[0]?.hash,
+        fillTxHash: statusResponse.swapDetails?.destinationChainTxHashes?.[0]?.hash,

This keeps status polling resilient when hashes are absent.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
status: NEAR_INTENTS_STATUS_TO_COW_STATUS[statusResponse.status] || BridgeStatus.UNKNOWN,
depositTxHash: statusResponse.swapDetails?.originChainTxHashes[0]?.hash,
fillTxHash: statusResponse.swapDetails?.destinationChainTxHashes[0]?.hash,
}
status: NEAR_INTENTS_STATUS_TO_COW_STATUS[statusResponse.status] || BridgeStatus.UNKNOWN,
depositTxHash: statusResponse.swapDetails?.originChainTxHashes?.[0]?.hash,
fillTxHash: statusResponse.swapDetails?.destinationChainTxHashes?.[0]?.hash,
}
🤖 Prompt for AI Agents
packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts around
lines 258 to 261: the current accesses
statusResponse.swapDetails?.originChainTxHashes[0]?.hash and
destinationChainTxHashes[0]?.hash can throw when the arrays are undefined;
change them to use optional chaining on the index (e.g.
statusResponse.swapDetails?.originChainTxHashes?.[0]?.hash and
statusResponse.swapDetails?.destinationChainTxHashes?.[0]?.hash) so the code
safely returns undefined when hashes are absent.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants