Skip to content

fix: deduplicate ERC20 batch approvals - #1992

Open
Mabolla wants to merge 1 commit into
ProjectOpenSea:mainfrom
Mabolla:agent/dedupe-erc20-batch-approvals
Open

fix: deduplicate ERC20 batch approvals#1992
Mabolla wants to merge 1 commit into
ProjectOpenSea:mainfrom
Mabolla:agent/dedupe-erc20-batch-approvals

Conversation

@Mabolla

@Mabolla Mabolla commented Aug 14, 2026

Copy link
Copy Markdown

Thanks for opening a PR!

We really appreciate you taking the time to contribute. It means a lot to the OpenSea team and the broader developer community.

A quick note about how this repo works

This repository is a read-only mirror of a package maintained in an internal monorepo. Because of that, pull requests cannot be merged directly here.

But don't worry -- your contribution won't be lost! Here's what happens next:

  1. Our team reviews every PR that comes in.
  2. If the change looks good, we'll recreate it internally in our monorepo.
  3. The fix will be synced back to this public repo on the next release.

We'll keep you posted on the PR as things progress.

Is this a bug report?

If you're reporting a bug rather than submitting a code fix, opening an issue is usually the fastest path to a resolution. Bug report issues help us triage and prioritize effectively.

Thanks again for helping make OpenSea better for everyone!


Summary

Deduplicates ERC20 approvals in batchApproveAssets when the same token contract appears multiple times, including addresses that differ only by casing.

Root cause

batchApproveAssets already tracks processed contract addresses for NFT approvals, but the ERC20 branch did not use that set. Duplicate entries could therefore generate multiple identical approve(conduit, MAX_UINT256) calls and unnecessarily take the multicall path.

Changes

  • Normalize ERC20 contract addresses to lowercase before deduplication.
  • Reuse processedContracts so only one unlimited approval is generated per ERC20 contract.
  • Add a deterministic regression test covering duplicate ERC20 entries with different address casing.

Validation

  • Regression test reproduced the duplicate-approval behavior before the fix and passes after it.
  • Targeted tests: 11/11 passed.
  • Full unit suite: 928/928 passed across 41 test files.
  • Biome check passes for the two changed files.

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.

1 participant