Swapping with Permit2

Permit2 is Uniswap's universal token approval system that enables gasless approvals after a one-time setup. Instead of approving each protocol separately, you approve Permit2 once and then use off-chain signatures for all subsequent token transfers.

Why Use Permit2?

  • Cost Savings - After the initial approval, no gas is required for future approvals
  • Better Security - Permits are time-limited and can specify exact amounts
  • Improved UX - Users sign a message instead of submitting a transaction

How It Works

  1. One-Time Setup - Approve your tokens to the Permit2 contract (can be max amount)
  2. Get Quote - Request a quote with isPermit2: true flag
  3. Create Order - The SDK generates a Permit2 signature bundled with your order
  4. Submit - The relayer verifies the signature and executes the swap

Interactive Code Example

Explore the complete implementation — this example demonstrates swapping USDC to WETH using Permit2:

Did you find what you need?