Overview
ThePermit2IntentExecutor enables intent execution leveraging Uniswap’s Permit2 system for efficient token permission management with gasless approvals.
Source: /src/executor/Permit2Intent/Permit2Executor.sol:43
Key Features
- Gasless Token Approvals: Use EIP-712 structured signatures instead of on-chain approval transactions
- Nonce-Based Replay Protection: Efficient storage patterns for per-account nonce tracking
- EIP-1271 Validation: Support for both EOA and smart contract account signatures
- Cross-Chain Support: Origin and destination chain execution with Permit2 authorization
Execution Flow
- User signs a Permit2-compatible intent with token permissions and operations
- Arbiter calls
executePreClaimOpsWithPermit2Stubto execute pre-claim operations - Contract validates the signature against Permit2’s domain separator
- Nonce is consumed to prevent replay attacks
- Pre-claim operations are executed (e.g., token transfers, swaps)
- For cross-chain:
executeTargetOpsWithPermit2Stubexecutes on destination
Structs
EIP712Permit2Stub
Core Permit2 parameters for intent execution.uint256
Nonce for replay protection, unique per account
uint256
Expiration timestamp for the permit
EIP712Permit2MandateStub
Mandate-specific parameters for Permit2 intent execution on origin chain.bytes32
Hash of input token details
uint128
Minimum gas required for execution of operations
bytes32
Hash of target attributes (account, tokenOut, chain, expires)
bytes32
Hash of destination operations to execute
bytes32
Hash of qualifier data specific to this mandate
EIP712Permit2MandateDestinationStub
Mandate-specific parameters for Permit2 destination chain execution.address
Original sponsor address from the origin chain
address
Arbiter that facilitated the cross-chain transfer
uint128
Minimum gas required for pre-claim operations
uint256
Chain ID where the order was originally notarized
bytes32
Hash of pre-claim operations from origin chain
bytes32
Hash of input token details
bytes32
Hash of qualifier data
Target
Target parameters for fill validation
Target
Target chain fill parameters for Permit2 destination execution.uint256
Deadline timestamp for completing the fill
bytes32
Hash of expected output tokens
Functions
executePreClaimOpsWithPermit2Stub
address
required
The user account that signed the intent and will execute operations
EIP712Permit2Stub
required
Core Permit2 parameters including nonce and expiration
EIP712Permit2MandateStub
required
Mandate-specific parameters including token and operation hashes
Types.Operation
required
Array of operations to execute on the origin chain
bytes
required
EIP-712 signature from the account authorizing the operations
bytes32 - The computed Permit2 hash used for signature validation
The function immediately consumes the nonce to prevent replay attacks before validating the signature and executing operations.
executeTargetOpsWithPermit2Stub
address
required
The user account that signed the intent and will execute operations
EIP712Permit2Stub
required
Core Permit2 parameters including nonce and expiration
EIP712Permit2MandateDestinationStub
required
Mandate-specific parameters including token and operation hashes for destination
Types.Operation
required
Array of operations to execute on the destination chain
bytes
required
EIP-712 signature from the account authorizing the operations
bytes32 - The computed Permit2 hash used for signature validation
isPermit2IntentNonceConsumed
uint256
required
The nonce value to check
address
required
The account address that owns the nonce
bool - True if the nonce has been consumed, false otherwise
Signature Validation
The contract uses EIP-712 signature validation with Permit2’s domain separator:Hash Computation
- Mandate Hash: Combines target attributes, operation hashes, and qualifier data
- Permit2 Hash: Combines mandate hash with Permit2-specific fields (token, arbiter, nonce, expires)
- Typed Data Digest: Wraps Permit2 hash with domain separator for final signature validation
Validation Modes
Supports multiple signature validation modes via theValidateSignature base contract:
- ERC1271: Direct signature validation
- EMISSARY: Session key validation
- Hybrid Modes: Fallback combinations for flexibility
Example Usage
Gas Optimization
Error Handling
error
Thrown when signature validation fails using any configured validation mode
error
Thrown when fill expiration has passed or chain validation fails
error
Thrown when
executeTargetOpsWithPermit2Stub is called by non-router addressSecurity Considerations
Benefits over Standard Approvals
- Gas Savings: No separate approval transaction needed
- Better UX: Single signature for approval + operation
- Granular Control: Per-intent token permissions instead of unlimited approvals
- Cross-Chain: Works seamlessly across chains with consistent signatures
Related
- IntentExecutor - Main executor contract
- CompactIntentExecutor - Compact protocol execution
- StandaloneIntentExecutor - Self-contained execution