Signing and Authorization
AgentSwap Intents relies entirely on the canonical Permit2 contract for token pull authorization and signature verification. The protocol uses the PermitWitnessTransferFrom path, avoiding custom EIP-712 domain mirrors that can drift out of sync.
The Permit2 Allowance
Section titled “The Permit2 Allowance”Before a user can sign an intent, they must grant a standard ERC-20 allowance for their tokenIn to the Permit2 singleton contract.
This is the actual on-chain gate: at fill time Permit2 must still hold enough allowance to pull amountIn. Nothing in the protocol constrains how that allowance is granted — an unlimited approval made once, or an exact approval refreshed per order, both work. IntentLens.preview reports ownerPermit2Allowance for exactly this reason.
The Witness
Section titled “The Witness”The user signs a Permit2 witness rather than a plain EIP-712 message.
The primary type is PermitWitnessTransferFrom. The signature is verified against Permit2’s own EIP-712 domain (name: "Permit2", verifyingContract = Permit2’s address). The settlement contract explicitly reads PERMIT2.DOMAIN_SEPARATOR() to construct the verification digest, ensuring the two can never drift.
The witness type is named IntentWitness:
IntentWitness(address owner,address recipient,address tokenIn,uint256 amountIn,address tokenOut,uint256 startAmountOut,uint256 endAmountOut,uint256 startTime,uint256 decayEndTime,uint256 endTime,bytes32 appData)The full witness type string handed to Permit2 is:
IntentWitness witness)IntentWitness(address owner,address recipient,address tokenIn,uint256 amountIn,address tokenOut,uint256 startAmountOut,uint256 endAmountOut,uint256 startTime,uint256 decayEndTime,uint256 endTime,bytes32 appData)TokenPermissions(address token,uint256 amount)Within the Permit2 transfer details, spender is set to the IntentSettlerV1 address, deadline is bound to the order’s endTime, and permitted is set to TokenPermissions(tokenIn, amountIn).
The permitDigest(order) function provides a view method returning the exact digest Permit2 will verify, allowing clients to sign correctly and relayers to validate the signature before spending gas.
Cancellation Signatures
Section titled “Cancellation Signatures”While the order creation signature relies on the Permit2 domain, gasless off-chain cancellations are signed against the settler’s own domain.
The cancellation typehash is CancelIntent(bytes32 orderHash,uint256 deadline) under the domain EIP712("AgentSwap IntentSettler", "1"). This domain separation is intentional and securely isolates order authorizations from explicit cancellations.