Skip to content

chore: upgrade cow-sdk 7.3.4 -> 9.2.7 - #3101

Merged
mgrabina merged 1 commit into
mainfrom
cow-sdk-v9-upgrade
Sep 10, 2026
Merged

chore: upgrade cow-sdk 7.3.4 -> 9.2.7#3101
mgrabina merged 1 commit into
mainfrom
cow-sdk-v9-upgrade

Conversation

@mgrabina

@mgrabina mgrabina commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Two major versions of @cowprotocol/cow-sdk, plus the flash-loans and ethers-v5 adapter packages that move with it.

package from to
@cowprotocol/cow-sdk 7.3.4 9.2.7
@cowprotocol/sdk-flash-loans 1.7.4 3.3.4
@cowprotocol/sdk-ethers-v5-adapter 0.3.5 0.4.11

9.2.7 rather than the latest 9.2.9: pnpm-workspace.yaml quarantines releases younger than 7 days and 9.2.8/9.2.9 are still inside that window. They become installable on Sep 14 if we want to bump again before merging.

Breaking changes adapted

SupportedChainId dropped LENS (v8) and added SOLANA (v9). Removes the Lens entries and adds Solana to the four exhaustive Record<SupportedChainId, string> maps in cow.constants.ts. Solana is not in CoWProtocolSupportedNetworks, so the Lens "safe check" entry in COW_UNSUPPORTED_ASSETS was already unreachable and goes with it.

sdk-flash-loans v3 changed CollateralSwapOrder from {sellAmount, buyAmount} to a single flashLoanAmount, reading the buy side off orderToSign.buyAmount instead. Values are unchanged at all three call sites: orderToSign.buyAmount already held the old buyAmount, and calculateFlashLoanAmounts is untouched, so flashLoanAmount = orderToSign.sellAmount + flashLoanFeeAmount resolves to exactly the old sellAmount.

OrderParameters gained gasAmount / gasPrice / sellTokenPrice, which are quote-response-only fields, so UnsignedOrder no longer satisfies it. The two places that hold an orderToSign (CowProtocolRatesType.order, CowProtocolActionParams.quote) are retyped to UnsignedOrder, which is what they actually hold.

cow-sdk #800 (shipped in 7.3.5+) fixed the inverted beforeNetworkCosts / afterNetworkCosts labels for SELL orders. Only the sellAmount fields swapped; buyAmount kept its meaning. Both branches of getCowProtocolSellRates now collapse to beforeNetworkCosts, which reproduces the previously displayed amounts exactly for SELL and BUY alike.

This closes #2886, which targeted the same #800 fix at 7.3.8. Note that #2886's buy-side change was wrong: it moved the destination amount to afterNetworkCosts.buyAmount, which understates the displayed output by the network fee on SELL quotes. Running both SDK versions on identical inputs (S=0.99 WETH, B=3000 USDC, F=0.01 WETH):

what the UI showed on 7.3.4:  src=1.0 WETH   dst=3030.303030 USDC
this PR (beforeNC/beforeNC):  src=1.0 WETH   dst=3030.303030 USDC   match
#2886   (beforeNC/afterNC):   src=1.0 WETH   dst=3000.000000 USDC   off by the network fee

The v9.0.0 "bring cow.fi back" break is a revert of a v8.1.0 domain change we never shipped, so it is a no-op here. The sdk-order-book v4 /solver_competition v2 migration and the AppDataSdk.legacy removal in sdk-app-data v6 touch APIs we do not call.

Verification

tsc --noEmit clean, eslint 0 errors, prettier clean. All 33 symbols imported from @cowprotocol/* confirmed to resolve at runtime in the new ESM builds. Runtime constants diffed old vs new: only BARN_ETH_FLOW_ADDRESSES moved, which we do not read (see below).

pnpm test:ci fails the same way here as on a pristine --frozen-lockfile tree at 7.3.4 — same 4 suites, same 3 tests, a jest ESM transform issue unrelated to this change. CI does not run jest.

CI is green: build, next_js_analyze, deploy, i18n and the full cypress matrix all pass. (pnpm build does fail in my local worktree on @narval-xyz/connect -> ox -> @noble/curves, but that is an artifact of the worktree resolving a hoisted node_modules outside its own tree, not a repo problem — CI builds this branch fine.)

Needs a human on preview

The swap paths need exercising against a live CoW backend, which I cannot do locally: a SELL quote (input amount and output amount should read the same as production), a BUY quote, and one flash-loan flow per adapter type (collateral swap, debt swap, repay with collateral) to confirm the flashLoanAmount change produces the same hooks.

Follow-up, not in this PR

The SDK's BARN_ETH_FLOW_ADDRESSES[1] moved from 0x04501b9b... to 0xb37aDD6A..., and cow.constants.ts still hardcodes the old value as COW_PROTOCOL_ETH_FLOW_ADDRESS_STAGING. It is unreachable today because COW_ENV is a hardcoded 'prod', and the prod address still matches the SDK. Worth a separate change pointing both constants at the SDK's exported address lists rather than hardcoding them.

Two major versions. Adapts the four breaking changes that affect us:

- SupportedChainId dropped LENS (v8) and added SOLANA (v9). Removes the
  Lens entries and adds Solana to the exhaustive chain records in
  cow.constants.ts. Solana is not in CoWProtocolSupportedNetworks, so the
  dead Lens safe-check entry goes with it.

- sdk-flash-loans v3 replaced CollateralSwapOrder's {sellAmount, buyAmount}
  with a single flashLoanAmount; the buy side is now read off
  orderToSign.buyAmount. Values are unchanged at all three call sites:
  orderToSign.buyAmount already held the old buyAmount, and
  flashLoanAmount = orderToSign.sellAmount + flashLoanFeeAmount resolves to
  the old sellAmount.

- OrderParameters gained gasAmount/gasPrice/sellTokenPrice, which are
  quote-response-only, so UnsignedOrder no longer satisfies it. The two
  places that held an orderToSign are retyped to UnsignedOrder.

- cow-sdk PR #800 (in 7.3.5+) fixed the inverted beforeNetworkCosts /
  afterNetworkCosts labels for SELL orders. Only the sellAmount fields
  swapped; buyAmount kept its meaning. Both branches in getCowProtocolSellRates
  now collapse to beforeNetworkCosts, which reproduces the previous displayed
  amounts exactly for both SELL and BUY.

Pinned to 9.2.7 rather than 9.2.9: pnpm-workspace.yaml quarantines releases
younger than 7 days and 9.2.8/9.2.9 are still inside that window.

The v9.0.0 "bring cow.fi back" break is a revert of a v8.1.0 domain change we
never shipped, so it is a no-op here.
@odin-by-borg

odin-by-borg Bot commented Sep 10, 2026

Copy link
Copy Markdown

Mjolnir Security Review

VerdictCLEAN · 0 findings
Commit51df175 · 1m 0s

No security vulnerabilities identified in this PR. The changes are a straightforward dependency upgrade of CoW Protocol SDK packages (cow-sdk 7.3.4 → 9.2.7, sdk-ethers-v5-adapter 0.3.5 → 0.4.11, sdk-flash-loans 1.7.4 → 3.3.4) with corresponding API adaptations: OrderParameters renamed to UnsignedOrder, flash loan parameters simplified from {sellAmount, buyAmount} to {flashLoanAmount}, chain enum updates (LENS removed, SOLANA added with empty/disabled addresses), and rate calculation logic simplified. The removal of ipfs-only-hash and its transitive dependencies (protobufjs, rabin-wasm, etc.) reduces the overall attack surface, which is a positive security change. The newly added SupportedChainId.SOLANA is not included in CoWProtocolSupportedNetworks and has empty adapter addresses, so it remains effectively disabled.

View in Odin


18 PRs reviewed · 1 finding

@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
interface Ready Ready Preview Sep 10, 2026 3:34pm UTC

Request Review

@github-actions

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

🎉 Global Bundle Size Decreased

Page Size (compressed)
global 1.32 MB (🟢 -3.71 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Four Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/bridge 38.1 KB (🟡 +369 B) 1.36 MB
/governance 43.3 KB (🟡 +369 B) 1.36 MB
/governance/ipfs-preview 101.62 KB (🟢 -33 B) 1.42 MB
/governance/v3/proposal 89.12 KB (🟡 +338 B) 1.41 MB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

@github-actions

Copy link
Copy Markdown

@mgrabina
mgrabina merged commit a4295d4 into main Sep 10, 2026
28 checks passed
@mgrabina
mgrabina deleted the cow-sdk-v9-upgrade branch September 10, 2026 19:59
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.

3 participants