Skip to content

fix(zero-approval): stop logging expected USDT approve revert as an error - #7775

Merged
limitofzero merged 1 commit into
cowprotocol:mainfrom
tenderdeve:fix/7547-usdt-approve-scary-log
Jun 30, 2026
Merged

limitofzero merged 1 commit into
cowprotocol:mainfrom
tenderdeve:fix/7547-usdt-approve-scary-log

Conversation

@tenderdeve

Copy link
Copy Markdown
Contributor

Summary

Fixes #7547

shouldZeroApprove figures out whether a token needs its allowance reset to zero first (USDT and friends) by simulating the approve and catching the revert. That revert is expected — it's the whole detection mechanism — but it was logged with console.error(e) where e is the full viem BaseError, so the console filled with a scary red stack (viem docs links, version, etc.) on every sell-amount change.

Now the expected first-pass revert is a quiet console.debug breadcrumb, and the genuinely-unexpected case (the zero-amount approve also reverting) is a console.warn. Both log only the error's shortMessage instead of the whole multi-line viem error.

To Test

  1. On Ethereum, have e.g. 2 USDT approved to the CoW vault relayer.
  2. Enter a sell amount greater than the current approval (e.g. 4 USDT) and open the console.
  • No red shouldZeroApprove #1 error stack with the viem error dump.
  • At most a greyed-out debug breadcrumb; the zero-approval flow still works (USDT still prompts the reset-to-zero step).

Background

The expected-revert path fires reactively on every keystroke via the zero-approval warning hook, so the noisy log was especially spammy.

…rror

shouldZeroApprove detects USDT-style tokens (which require resetting the
allowance to zero before setting a new one) by simulating the approve and
catching the revert. That revert is expected, but it was logged via
console.error with the full viem BaseError, flooding the console with a scary
red stack on every sell-amount change.

Log the expected first-pass revert as a quiet console.debug breadcrumb and the
genuinely-unexpected zero-amount revert as a console.warn, using only the
error's shortMessage instead of the whole multi-line viem error.
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

@tenderdeve is attempting to deploy a commit to the cow-dev Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ef71b356-767f-4829-8e42-e4e673fae828

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@elena-zh elena-zh added the trigger-preview Add to a fork PR to trigger CF-pages preview. See https://github.com/cowprotocol/cowswap/pull/7615 label Jun 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Cloudflare Pages preview mirror

Preview branch URL: https://github.com/cowprotocol/cowswap/tree/cf-preview/pr-7775
Mirror PR: #7776
Cloudflare Pages preview links will be posted on the mirror PR by the Cloudflare Pages GitHub integration once builds complete.

Source fork branch: tenderdeve/cowswap:fix/7547-usdt-approve-scary-log
Approval target SHA: 1ba93d8f6749
Last mirrored SHA: 1ba93d8f6749
Last comment update: @elena-zh at 2026-06-30T14:21:47.397Z

  • Sync Cloudflare preview to approval target commit

@github-actions github-actions Bot removed the trigger-preview Add to a fork PR to trigger CF-pages preview. See https://github.com/cowprotocol/cowswap/pull/7615 label Jun 30, 2026
@vercel
vercel Bot temporarily deployed to Preview – storybook June 30, 2026 14:22 Inactive
@vercel
vercel Bot temporarily deployed to Preview – widget-configurator June 30, 2026 14:23 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cowfi June 30, 2026 14:24 Inactive

@elena-zh elena-zh 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.

Thank you, looks good

@elena-zh
elena-zh requested a review from limitofzero June 30, 2026 14:57
@limitofzero
limitofzero merged commit b42836a into cowprotocol:main Jun 30, 2026
27 of 28 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 30, 2026
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.

3 participants