Skip to content

Conversation

@Foulks-Plb
Copy link
Contributor

@Foulks-Plb Foulks-Plb commented Jan 16, 2026

This PR moves the reset-approval logic for USDT-like tokens to ensure that each approval properly accounts for the reset when required.

The error came from fallback logic when supportSignature was set to false, which didn’t account for the approval reset.

@Foulks-Plb Foulks-Plb self-assigned this Jan 16, 2026
@linear
Copy link

linear bot commented Jan 16, 2026

@Foulks-Plb Foulks-Plb marked this pull request as ready for review January 16, 2026 09:52
const txRequirements: TransactionRequirement[] = [];

// Handle USDT-like tokens that require reset to 0 before changing allowance.
if (APPROVE_ONLY_ONCE_TOKENS[chainId]?.includes(token) && amount > 0n) {
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Do we have a test suite ?
  • Should we add tests for such critical element update?

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c493571596

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 136 to 139
else if (useSimpleTransfer) {
if (
APPROVE_ONLY_ONCE_TOKENS[data.chainId]?.includes(address) &&
erc20Allowances["bundler3.generalAdapter1"] > 0n
)
operations.push({
type: "Erc20_Approve",
sender: from,
address,
args: {
amount: 0n,
spender: generalAdapter1,
},
});
operations.push({
type: "Erc20_Approve",
sender: from,

Choose a reason for hiding this comment

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

P1 Badge Preserve zero-approve op so simulation doesn't throw

For approve-only-once tokens (e.g., USDT), simulateOperation still uses handleErc20ApproveOperation to throw NonZeroAllowanceError when the current allowance is non‑zero and a new non‑zero approve is simulated (packages/simulation-sdk/src/handlers/erc20/approve.ts). By removing the explicit 0-approve operation here, the bundle simulation will now fail whenever a user already has a non‑zero allowance to generalAdapter1 (or permit2 in the other branch) and needs to increase it, even though encodeErc20Approval later adds a reset only at encoding time. That means bundling can abort before encoding in the common “non‑zero existing allowance” case for USDT-like tokens.

Useful? React with 👍 / 👎.

Copy link
Collaborator

@Rubilmax Rubilmax left a comment

Choose a reason for hiding this comment

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

See codex comment and let's chat if blocked

@Foulks-Plb Foulks-Plb closed this Jan 16, 2026
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