Skip to content

feat: use CCTP v2 for bungee instead of CCTP v1 - #822

Draft
alfetopito wants to merge 15 commits into
mainfrom
fix/bungee-cctp-v2
Draft

feat: use CCTP v2 for bungee instead of CCTP v1#822
alfetopito wants to merge 15 commits into
mainfrom
fix/bungee-cctp-v2

Conversation

@alfetopito

@alfetopito alfetopito commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Use CCTP v2 for bungee instead of CCTP v1

Merged #824 into this PR

Testing

  • Unit tests
  • Will add it to CoW Swap to test

Summary by CodeRabbit

  • Updates

    • Bridge identifier changed to "cctp-v2" and display name updated to "Circle CCTP V2"
    • Bridge list normalization now treats "cctp" as "cctp-v2"
  • New Features

    • Improved handling of output amounts for CCTP V2 enabling proportional fee adjustments based on actual bridged amounts
  • Documentation

    • Examples and configuration references updated to use "cctp-v2"
  • Tests

    • Added and activated tests covering CCTP V2 decoding and fee-adjustment logic

@alfetopito alfetopito self-assigned this Mar 12, 2026
@coderabbitai

coderabbitai Bot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@shoom3301, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f1a1a652-4db1-4738-87fa-1cca08338245

📥 Commits

Reviewing files that changed from the base of the PR and between ee5fd9b and 1061355.

📒 Files selected for processing (8)
  • packages/bridging/src/providers/bungee/BungeeApi.test.ts
  • packages/bridging/src/providers/bungee/BungeeApi.ts
  • packages/bridging/src/providers/bungee/createBungeeDepositCall.test.ts
  • packages/bridging/src/providers/bungee/createBungeeDepositCall.ts
  • packages/bridging/src/providers/bungee/testData.ts
  • packages/bridging/src/providers/bungee/types.ts
  • packages/bridging/src/providers/bungee/util.test.ts
  • packages/bridging/src/providers/bungee/util.ts
📝 Walkthrough

Walkthrough

The Bungee bridge provider is updated to support CCTP V2 instead of CCTP. Changes include updating bridge identifiers across type definitions and constants, adding support for optional outputAmount handling in transaction data encoding and decoding, updating configuration examples, and adding comprehensive test coverage for the new functionality.

Changes

Cohort / File(s) Summary
Type Definitions & Enums
packages/bridging/src/providers/bungee/types.ts
Updated SupportedBridge type and BungeeBridge enum to use 'cctp-v2' instead of 'cctp'. Renamed CircleCCTP to CircleCCTPV2. Expanded BungeeTxDataBytesIndicesType to support both InputAmountTxDataBytesIndices and InputOutputAmountTxDataBytesIndices. Added GNOSIS_NATIVE to BungeeBridgeName enum.
Constants & Configuration
packages/bridging/src/providers/bungee/consts.ts, packages/bridging/src/providers/bungee/const/misc.ts
Updated SUPPORTED_BRIDGES array from 'cctp' to 'cctp-v2'. Modified BungeeTxDataBytesIndices to use 'cctp-v2' key with updated monitored address and new outputAmount field containing bytes indices and metadata.
Core Implementation
packages/bridging/src/providers/bungee/createBungeeDepositCall.ts, packages/bridging/src/providers/bungee/util.ts
Added conditional handling for optional outputAmount in calldata encoding. Updated decodeAmountsBungeeTxData to optionally return outputAmountBytes and outputAmountBigNumber alongside input amount data. Import added for InputOutputAmountTxDataBytesIndices.
Tests
packages/bridging/src/providers/bungee/createBungeeDepositCall.test.ts, packages/bridging/src/providers/bungee/util.test.ts
New comprehensive test suite for createBungeeDepositCall covering cctp-v2 calldata encoding, fee amount adjustments based on bridged amount variance, and modifyCalldataParams verification. Updated util.test.ts expectations for bridge identifiers and added decodeAmountsBungeeTxData tests.
Comments & Documentation
packages/bridging/src/providers/bungee/BungeeBridgeProvider.ts, packages/bridging/src/providers/bungee/getBridgingStatusFromEvents.ts, packages/bridging/src/README.md
Updated comment references from 'cctp' to 'cctp-v2'. Updated README examples showing includeBridges arrays and configuration snippets to use 'cctp-v2' identifier.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hopity-hop through the bridge we go,
From CCTP to V2, watch the outputs flow!
Identifiers updated with a gentle bounce,
New output amounts now decoded per ounce,
Tests hopping in to catch every case! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately and specifically summarizes the primary change: replacing CCTP v1 with CCTP v2 for the bungee integration, which is reflected across all modified files.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/bungee-cctp-v2

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.

@alfetopito

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@github-actions

github-actions Bot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

📦 GitHub Packages Published

Last updated: Jul 20, 2026, 10:15:49 AM UTC

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

  • @cowprotocol/cow-sdk@9.2.2-pr-822-10613551.0
  • @cowprotocol/sdk-app-data@5.3.1-pr-822-10613551.0
  • @cowprotocol/sdk-bridging@4.2.2-pr-822-10613551.0
  • @cowprotocol/sdk-common@0.12.0-pr-822-10613551.0
  • @cowprotocol/sdk-composable@1.1.2-pr-822-10613551.0
  • @cowprotocol/sdk-config@2.3.1-pr-822-10613551.0
  • @cowprotocol/sdk-contracts-ts@3.2.1-pr-822-10613551.0
  • @cowprotocol/sdk-cow-shed@0.4.1-pr-822-10613551.0
  • @cowprotocol/sdk-ethers-v5-adapter@0.4.10-pr-822-10613551.0
  • @cowprotocol/sdk-ethers-v6-adapter@0.4.10-pr-822-10613551.0
  • @cowprotocol/sdk-flash-loans@3.2.2-pr-822-10613551.0
  • @cowprotocol/sdk-order-book@4.0.1-pr-822-10613551.0
  • @cowprotocol/sdk-order-signing@1.1.2-pr-822-10613551.0
  • @cowprotocol/sdk-subgraph@1.2.0-pr-822-10613551.0
  • @cowprotocol/sdk-trading@2.2.2-pr-822-10613551.0
  • @cowprotocol/sdk-viem-adapter@0.3.24-pr-822-10613551.0
  • @cowprotocol/sdk-weiroll@0.2.0-pr-822-10613551.0

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/cow-sdk@9.2.2-pr-822-10613551.0) or more conveniently by using the tag (@cowprotocol/cow-sdk@pr-822):

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

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

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

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

@alfetopito

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
packages/bridging/src/providers/bungee/types.ts (1)

184-188: Preserve bridge-specific typing for calldata indices.

This union lets cctp-v2 entries compile without outputAmount, so a future selector-map edit could silently disable the secondary proportional rewrite. A per-bridge mapping would keep the new Gnosis-native case without losing that safety check.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bridging/src/providers/bungee/types.ts` around lines 184 - 188, The
current BungeeTxDataBytesIndicesType uses a union value allowing selectors for
any bridge to omit outputAmount, which lets cctp-v2 entries compile without the
required outputAmount; change the type from a single union to a per-bridge
mapping so each bridge can enforce its own calldata shape. Concretely, replace
BungeeTxDataBytesIndicesType with a mapped type that lists each BungeeBridge key
explicitly (or uses a conditional mapped helper like BridgeCalldataIndices<K>)
and for cctp-v2 require Record<string, InputOutputAmountTxDataBytesIndices>
while other bridges keep Record<string, InputAmountTxDataBytesIndices> (or their
appropriate shapes); update any usage of BungeeTxDataBytesIndicesType to the new
per-bridge type so selector-map edits cannot drop outputAmount for cctp-v2.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bridging/src/providers/bungee/createBungeeDepositCall.test.ts`:
- Around line 11-12: CCTP_V2_TX_DATA is exported from a .test.ts file which
causes the test module (including describe() and beforeEach()) to be evaluated
when util.test.ts imports it; move the hex fixture into a non-test helper module
(e.g., fixtures.ts or testData.ts), export CCTP_V2_TX_DATA from that new file,
and update both createBungeeDepositCall.test.ts and util.test.ts to import
CCTP_V2_TX_DATA from the fixture module so the test file no longer exposes
exports that trigger the noExportsInTest rule.

In `@packages/bridging/src/providers/bungee/types.ts`:
- Line 3: The public type SupportedBridge was changed to drop the old alias
'cctp', which is a breaking change for callers using includeBridges: ['cctp'];
restore backwards compatibility by re-adding 'cctp' to the SupportedBridge union
in types.ts and keep runtime validation using SUPPORTED_BRIDGES, but normalize
any incoming 'cctp' value to the canonical 'cctp-v2' internally (e.g., in the
code paths that read includeBridges and in the function that builds/validates
SUPPORTED_BRIDGES). Update normalization logic that consumes includeBridges so
both typed callers and runtime configs accept 'cctp' but are treated as
'cctp-v2' downstream.

In `@packages/bridging/src/providers/bungee/util.ts`:
- Around line 223-236: Add explicit bounds checks before slicing calldata so
truncated txData cannot produce silently smaller BigInt values: for both the
optional outputAmount (functionParams.outputAmount.bytesString_startIndex +
functionParams.outputAmount.bytesString_length) and the inputAmount counterpart,
verify that txData has at least that many hex characters (accounting for the
"0x" prefix if present) and throw/reject if not; perform these checks in the
same block that currently reads txData and only call slice() and BigInt() after
the checks pass, referencing functionParams, txData,
outputAmount.bytesString_startIndex/bytesString_length and the analogous
inputAmount fields to locate and protect both decodings.
- Around line 161-164: The JSDoc example for objectToSearchParams shows an
incorrect serialized output; update the example string to match
URLSearchParams.toString() behavior (no leading '?' and commas percent-encoded).
Specifically, change the example result to:
userAddress=0x123&includeBridges=across%2Ccctp-v2 so it accurately reflects the
output of objectToSearchParams/URLSearchParams.

---

Nitpick comments:
In `@packages/bridging/src/providers/bungee/types.ts`:
- Around line 184-188: The current BungeeTxDataBytesIndicesType uses a union
value allowing selectors for any bridge to omit outputAmount, which lets cctp-v2
entries compile without the required outputAmount; change the type from a single
union to a per-bridge mapping so each bridge can enforce its own calldata shape.
Concretely, replace BungeeTxDataBytesIndicesType with a mapped type that lists
each BungeeBridge key explicitly (or uses a conditional mapped helper like
BridgeCalldataIndices<K>) and for cctp-v2 require Record<string,
InputOutputAmountTxDataBytesIndices> while other bridges keep Record<string,
InputAmountTxDataBytesIndices> (or their appropriate shapes); update any usage
of BungeeTxDataBytesIndicesType to the new per-bridge type so selector-map edits
cannot drop outputAmount for cctp-v2.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 38273703-8580-4de1-abab-719e153a9e3e

📥 Commits

Reviewing files that changed from the base of the PR and between 1a22c69 and ee5fd9b.

📒 Files selected for processing (10)
  • packages/bridging/src/README.md
  • packages/bridging/src/providers/bungee/BungeeBridgeProvider.ts
  • packages/bridging/src/providers/bungee/const/misc.ts
  • packages/bridging/src/providers/bungee/consts.ts
  • packages/bridging/src/providers/bungee/createBungeeDepositCall.test.ts
  • packages/bridging/src/providers/bungee/createBungeeDepositCall.ts
  • packages/bridging/src/providers/bungee/getBridgingStatusFromEvents.ts
  • packages/bridging/src/providers/bungee/types.ts
  • packages/bridging/src/providers/bungee/util.test.ts
  • packages/bridging/src/providers/bungee/util.ts

Comment thread packages/bridging/src/providers/bungee/createBungeeDepositCall.test.ts Outdated
Comment thread packages/bridging/src/providers/bungee/types.ts Outdated
Comment thread packages/bridging/src/providers/bungee/util.ts
Comment thread packages/bridging/src/providers/bungee/util.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/bridging/src/providers/bungee/BungeeApi.test.ts (1)

152-164: Add one more case for alias+canonical deduping.

You already test normalization; adding ['cctp', 'cctp-v2', 'across'] would lock in dedupe behavior too.

Suggested test addition
+    it('should normalize and dedupe when both "cctp" and "cctp-v2" are provided', async () => {
+      const request: BungeeQuoteAPIRequest = {
+        ...mockQuoteRequest,
+        includeBridges: ['cctp', 'cctp-v2', 'across'],
+      }
+
+      await api.getBungeeQuote(request)
+
+      expect(mockFetch).toHaveBeenCalledWith(
+        expect.stringContaining('includeBridges=cctp-v2%2Cacross'),
+        expect.any(Object),
+      )
+    })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bridging/src/providers/bungee/BungeeApi.test.ts` around lines 152 -
164, Add a test that verifies alias+canonical deduping by calling
api.getBungeeQuote with a BungeeQuoteAPIRequest whose includeBridges includes
both 'cctp' and 'cctp-v2' (e.g., ['cctp', 'cctp-v2', 'across']) and assert
mockFetch was called with a URL containing the deduped, normalized parameter
'includeBridges=cctp-v2%2Cacross'; locate this behavior around the existing test
that calls getBungeeQuote and uses mockFetch and BungeeQuoteAPIRequest to mirror
the normalization case and confirm duplicates are removed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/bridging/src/providers/bungee/BungeeApi.test.ts`:
- Around line 152-164: Add a test that verifies alias+canonical deduping by
calling api.getBungeeQuote with a BungeeQuoteAPIRequest whose includeBridges
includes both 'cctp' and 'cctp-v2' (e.g., ['cctp', 'cctp-v2', 'across']) and
assert mockFetch was called with a URL containing the deduped, normalized
parameter 'includeBridges=cctp-v2%2Cacross'; locate this behavior around the
existing test that calls getBungeeQuote and uses mockFetch and
BungeeQuoteAPIRequest to mirror the normalization case and confirm duplicates
are removed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 47021732-c92f-4dee-8324-b16c8c29e835

📥 Commits

Reviewing files that changed from the base of the PR and between ee5fd9b and afa2cab.

📒 Files selected for processing (9)
  • packages/bridging/src/providers/bungee/BungeeApi.test.ts
  • packages/bridging/src/providers/bungee/BungeeApi.ts
  • packages/bridging/src/providers/bungee/consts.ts
  • packages/bridging/src/providers/bungee/createBungeeDepositCall.test.ts
  • packages/bridging/src/providers/bungee/createBungeeDepositCall.ts
  • packages/bridging/src/providers/bungee/testData.ts
  • packages/bridging/src/providers/bungee/types.ts
  • packages/bridging/src/providers/bungee/util.test.ts
  • packages/bridging/src/providers/bungee/util.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bridging/src/providers/bungee/util.ts

@alfetopito
alfetopito force-pushed the fix/bungee-cctp-v2 branch from 9fce3a1 to 9a57584 Compare June 15, 2026 17:31
@shoom3301
shoom3301 marked this pull request as ready for review July 20, 2026 10:12
@shoom3301
shoom3301 marked this pull request as draft July 20, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants