Skip to content

Only the first ERC20 to ERC20 swap works with tradeCoin #532

@cryptomarabout

Description

@cryptomarabout

When using the Zora SDK’s tradeCoin to swap from an ERC20 to another ERC20, only the first transaction works.
After that, all swaps revert.

The SDK is supposed to handle the approve / permit part for ERC20 swaps automatically, but something is wrong with how approvals and permits are consumed.

Observed behavior

  • On the first transaction:

    • The SDK requires an approve infinite call
    • The SDK requires to sign to swap and approve the specific spending limit I want for my swap (via permit)
    • This transaction succeeds
  • On any following transactions:

    • The wallet simulation does not detect any change in the provided permit signature
    • The transaction reverts

(I've tested with multiple addresses and tokens)

Possible root cause

It seems that the infinite approval is being consumed by the contract, instead of using the amount specified in the permit signature.
As a result:

  • The first permit signature is never consumed
  • Any subsequent permit signatures cannot be validated, causing all following swaps to fail

Steps to reproduce

  1. Call tradeCoin to swap ERC20 → ERC20.
  2. Approve the infinite allowance, sign the specific spending permit and swap (transaction succeeds)
  3. Try another swap (transaction fails/reverts)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions