Overview
Adapters are protocol-specific settlement contracts that handle fill and claim operations through the Router. They use a delegatecall pattern to execute in the Router’s context, enabling modular protocol support without contract upgrades.Adapters are always executed via delegatecall from the Router, meaning they run in the Router’s storage and balance context.
Adapter Architecture
AdapterBase
All adapters inherit fromAdapterBase, which provides foundational functionality:
AdapterBase.sol
Router Reference
Immutable reference to the Router contract for security validation
Arbiter Reference
Arbiter contract responsible for settlement validation
onlyViaRouter Modifier
Ensures functions are only called via Router delegatecall
Relayer Context
Access to solver-specific context data
Delegatecall Pattern
Adapters use delegatecall to execute in the Router’s context:AdapterLib.sol
Delegatecall Security Model
- Execution Context
- Security Validation
- Wrong Usage
Relayer Context
Adapters receive solver-specific context data appended to calldata:AdapterBase.sol
Calldata Format
The Router appends relayer context to adapter calldata:SameChainAdapter.sol
Adapter Types
Fill Adapters
Handle settlement operations that fulfill user orders:SameChainAdapter.sol
Claim Adapters
Handle resource unlock operations:Implementation Requirements
1
Inherit from AdapterBase
2
Return Function Selector
3
Implement ERC165
4
Use onlyViaRouter
Example: IntentExecutorAdapter
A passthrough adapter that forwards calls to an intent executor:IntentExecutorAdapter.sol
Adapter Registration
Adapters are registered with the RouterManager:- Install
- Hotfix
- Retire
Adapter Tags
Adapters can specify metadata tags for routing behavior:Available Tag Flags
Available Tag Flags
- SKIP_RELAYER_CONTEXT: Adapter doesn’t consume relayer context
- Additional flags can be defined in future versions
Security Best Practices
Validate Delegatecall
Always use
onlyViaRouter modifier on external functionsTrusted Protocols Only
Only integrate with well-audited, trusted protocols
Return Selectors
All fill/claim functions must return their selector
Implement ERC165
Add all function selectors to
supportsInterfaceGas Optimizations
Adapters can optimize gas usage:Related Concepts
Arbiters
Learn about arbiter layer and resource unlocking
Router System
Understand how Router coordinates adapters