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
AdapterBase is an abstract base contract that provides foundational functionality for all settlement adapters in the Warp Router ecosystem. Adapters are always executed via delegatecall from the Router contract to handle cross-chain operations, token transfers, and settlement logic for specific protocols or chains.
Contract Details
Source:src/base/adapter/AdapterBase.sol
Inherits: IAdapter, SemVer, IIndexedEvents
Delegatecall Execution Context
When an adapter function is delegatecalled from the Router:address(this)equals_ROUTERdue to delegatecall context- The adapter executes in Router’s context with access to Router’s storage and balance
- This is enforced by the
onlyViaRoutermodifier which checksaddress(this) == _ROUTER
State Variables
_ROUTER
ARBITER
address(this) for self-arbitration.
Errors
OnlyDelegateCall
InvalidRelayerContext
Constructor
The Router contract address that will delegatecall into this adapter
The Arbiter contract address for settlement validation, or address(0) for self-arbitration
Modifiers
onlyViaRouter
Functions
_loadRelayerContext
_callAdapterWithRelayerContext function appends relayer context to adapter calls using:
- Reading the context length from the last 32 bytes of calldata
- Calculating the offset where relayer context begins
- Returning a calldata slice pointing to the relayer context
The length of the relayer context in bytes
The relayer context as a calldata slice ready for abi.decode by the adapter
supportsInterface
this.supportsInterface.selectortype(IAdapter).interfaceId
The function selector to check for support
bool - True if the selector is supported
settlementLayerSpender
address - The address authorized to spend tokens
ADAPTER_TAG
Constants.DEFAULT_ADAPTER_TAG.
Returns: bytes12 - The adapter tag
Implementation Guide
When creating a new adapter that inherits from AdapterBase, follow these critical guidelines:1. Function Signature Requirements
All fill/claim functions MUST return bytes4 (their own selector):2. Security Requirements
- NEVER make direct calls to untrusted external contracts
- Remember: adapters run in Router’s context via delegatecall
- Any storage writes affect Router’s storage, not adapter’s storage
- Use only trusted, audited protocols (e.g., Uniswap, AAVE, Compound)
3. IERC165 Implementation
OverridesupportsInterface to include all your fill/claim function selectors:
4. Relayer Context Usage
Use_loadRelayerContext() to retrieve relayer-provided data:
5. Token Handling
For adapters that need to handle token prefunding, useAdapterBasePrefund which provides:
_prefundRecipient(from, to, tokenOut, amountOut)for single token transfers_prefundRecipient(from, to, tokenOut[])for multiple token transfers- Automatic handling of both ERC20 and native ETH (Constants.NATIVE_TOKEN)
Related Contracts
- AdapterBasePrefund - Extension with token prefunding helpers
- SameChainAdapter - Same-chain settlement implementation
- MultiCallAdapter - Multi-call batching implementation
- IntentExecutorAdapter - Intent execution forwarding
AdapterBasePrefund
AdapterBasePrefund is an abstract contract that extends AdapterBase with token prefunding functionality.
Source: src/base/adapter/AdapterBasePrefund.sol
Functions
_prefundRecipient (Array)
The address providing the tokens (usually the Router or a solver)
The recipient address that will receive the prefunded tokens
Array of [tokenAddress, amount] pairs encoded as uint256[2]
_prefundRecipient (Single)
The address providing the tokens
The recipient address
The token address (Constants.NATIVE_TOKEN for ETH)
The amount to transfer