Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rhinestonewtf/warp-router/llms.txt
Use this file to discover all available pages before exploring further.
Overview
MultiCallAdapter enables solvers to execute multiple calls on behalf of users while ensuring proper token transfers and fee collection. It supports various fill operations including standard fills, fills with fees, and fills with both fees and refunds.
Source: src/arbiters/multicall/MultiCallAdapter.sol
Inherits: AdapterBasePrefund, Caller
Features
- Batched arbitrary call execution
- Solver compensation validation
- Token prefunding for users
- Support for native ETH and ERC20 tokens
- Just-In-Time (JIT) claim operations
- Payable multicalls with ETH value forwarding
Data Structures
FillData
Array of [token_address, amount] pairs representing solver payment. What the solver is being paid back in after executing the multicalls.
Array of [token_address, amount] pairs the solver transfers to user. What the solver pays the account before execution.
Batch of execution calls to perform. Each execution contains target, value, and calldata.
Target smart contract account for the operations.
ETH value to send with the multicall execution.
JITClaimData
Array of [token_address, amount] pairs for solver compensation.
Batch of execution calls for the JIT claim.
Errors
TokenNotPaidInMulticall
InvalidRelayerContext
Constructor
Address of the Warp Router contract that will delegatecall this adapter
The arbiter is set to
address(0) since multicall operations use a different validation pattern than traditional arbiters.Fill Functions
multicall_handleFill
Contains token transfers and multicall executions to perform
The function selector for verification (
this.multicall_handleFill.selector)- Extracts tokenIn recipient from relayer context
- Pre-funds user account with tokenOut
- Executes multicalls through arbiter
- Validates solver received expected tokenIn amounts
- Returns function selector
this.multicall_handleFill.selector
multicall_handleJITClaim
Contains tokenIn compensation and multicall executions
The function selector for verification (
this.multicall_handleJITClaim.selector)- Extracts tokenIn recipient from relayer context
- Executes multicalls through arbiter
- Validates solver received expected tokenIn amounts
- Returns function selector
this.multicall_handleJITClaim.selector
multicall_handlePayable
Amount of ETH to send with the multicall
Array of calls to execute
The function selector for verification (
this.multicall_handlePayable.selector)- Forwards ETH value and executions to arbiter’s
multiCallfunction - Returns function selector
this.multicall_handlePayable.selector
Internal Functions
_tokenInRecipient
abi.encodePacked(address(tokenInRecipient)) (20 bytes)
Returns:
The address designated to receive input tokens from the multicall
_handleMulticall
Contains all data for the fill operation
Address to receive tokenIn payments
- Prefunds user account:
_prefundRecipient(msg.sender, fillData.account, fillData.tokenOut) - Executes multicalls and validates tokenIn:
_multicallAssertTokenIn(...)
_multicallAssertTokenIn
Array of calls to execute
Expected token payments to solver
Address to receive the tokens
ETH value to send with the multicall
Helper Functions
__encodeRelayerData
Address to receive input tokens from the multicall
Packed bytes containing the recipient address:
abi.encodePacked(tokenInRecipient)Interface Support
supportsInterface
Function selector to check
True if the selector is supported. Supports:
this.multicall_handleFill.selectorthis.multicall_handleJITClaim.selectorthis.multicall_handlePayable.selector- Any selectors from AdapterBase
- Any selectors from Caller
type(IAdapter).interfaceId
Relayer Context
The relayer context must be exactly 20 bytes containing the tokenIn recipient address:Token Format
Tokens are represented asuint256[2] arrays:
tokenAddressis encoded as uint256 (useIdLib.toAddress()to convert)amountis the token amount in wei
For native ETH, use
Constants.NATIVE_TOKEN as the token address.Execution Flow Example
Security Considerations
Token Validation
The adapter validates that the solver receives expected tokenIn amounts by callingmultiCallWithDrainToken on the arbiter, which:
- Executes the multicalls
- Transfers tokenIn amounts to solver
- Reverts if expected tokens are not available
Gas Optimization
- Uses
uint256[2][]for efficient token encoding - Minimal data copying with calldata parameters
- Direct arbiter calls without intermediate proxying
- Optimized prefunding with
AdapterBasePrefundhelpers
Related Contracts
- AdapterBase - Base adapter functionality
- AdapterBasePrefund - Token prefunding helpers