Overview
IntentExecutorAdapter is a gas-optimized adapter contract that implements a transparent forwarding pattern for intent execution requests. It acts as a proxy between the router and the actual intent executor, minimizing gas overhead through memory-safe assembly operations.
Source: src/adapters/IntentExecutorAdapter.sol
Inherits: AdapterBase
Forwarding Pattern
The adapter uses memory-safe assembly for calldata forwarding to achieve minimal gas overhead, typically saving 200-500 gas per call compared to high-level Solidity forwarding patterns. It handles three types of intent execution patterns:- Compact intent execution (ERC-7683 style)
- Permit2 intent execution (with token approvals)
- Standalone multichain intent execution
- Standalone single-chain intent execution
This adapter does not consume any relayerContext data. It uses
ADAPTER_TAG with setSkipRelayerContext() flag.State Variables
EXECUTOR
Function Selectors
Cached function selectors for gas efficiency:Errors
ForwardingToExecutorFailed
Constructor
address
The address of the router contract that will call this adapter
address
The address of the intent executor contract that will handle forwarded calls
Fill Functions
handleFill_intentExecutor_handleCompactTargetOps
bytes
The ABI-encoded parameters for the compact intent execution, typically containing target operations, token amounts, and execution context
bytes4
The function selector of this function to confirm successful handling
- Router receives compact intent execution request
- Router calls this function with encoded parameters
- Function forwards to
executor.executeTargetOpsWithCompactStub(parameters) - Executor processes compact intent and executes target operations
this.handleFill_intentExecutor_handleCompactTargetOps.selector
Gas Optimization: Optimized forwarding saves gas compared to traditional proxy patterns
handleFill_intentExecutor_handlePermit2TargetOps
bytes
The ABI-encoded parameters for the Permit2 intent execution, including permit signatures, token details, and target operations
bytes4
The function selector of this function to confirm successful handling
- User signs Permit2 permit for token transfer
- Router receives intent execution request with permit signature
- Router calls this function with encoded permit and parameters
- Function forwards to
executor.executeTargetOpsWithPermit2Stub(parameters) - Executor validates permit signature and executes target operations
this.handleFill_intentExecutor_handlePermit2TargetOps.selector
handleFill_intentExecutor_executeMultichainOps
bytes
The ABI-encoded parameters for the multichain operation execution, containing cross-chain operation details and execution parameters
bytes4
The function selector of this function to confirm successful handling
- Router receives multichain operation request
- Router calls this function with encoded operation parameters
- Function forwards to
executor.executeMultichainOps(parameters) - Executor processes multichain operations across target chains
this.handleFill_intentExecutor_executeMultichainOps.selector
handleFill_intentExecutor_executeSinglechainOps
bytes
The ABI-encoded parameters for the single-chain operation execution, containing operation details and execution parameters
bytes4
The function selector of this function to confirm successful handling
- Router receives single-chain operation request
- Router calls this function with encoded operation parameters
- Function forwards to
executor.executeSinglechainOps(parameters) - Executor processes operations on the current chain
this.handleFill_intentExecutor_executeSinglechainOps.selector
Interface Support
supportsInterface
bytes4
The 4-byte interface selector to check for support
bool
True if the selector is supported by this contract. Supported selectors:
handleFill_intentExecutor_handleCompactTargetOps.selectorhandleFill_intentExecutor_handlePermit2TargetOps.selectorhandleFill_intentExecutor_executeMultichainOps.selectorhandleFill_intentExecutor_executeSinglechainOps.selector- Any selectors supported by AdapterBase
Adapter Tag
ADAPTER_TAG
skipRelayerContext flag set.
Returns:
bytes12
Constants.DEFAULT_ADAPTER_TAG.setSkipRelayerContext()Gas Optimization
The adapter usesAdapterCalldataPassthroughLib for efficient calldata forwarding:
- Saves 200-500 gas per call compared to high-level Solidity
- Uses zero-copy calldata forwarding with
calldatacopy - Minimizes memory allocation
- Properly propagates revert data from executor
The passthrough library is memory-safe and properly manages the free memory pointer to ensure compatibility with Solidity’s memory model.
Security Considerations
Usage Example
Related Contracts
- AdapterBase - Base adapter functionality
- IntentExecutor - Target executor contract