Skip to main content

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 from AdapterBase, which provides foundational functionality:
AdapterBase.sol
Key Components:

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

Critical Security Implications:
  • Adapters execute with Router’s storage and balance
  • msg.sender and msg.value are preserved from original call
  • address(this) equals Router address during execution
  • Storage writes affect Router’s state, not adapter’s state
  • Never make direct calls to untrusted contracts from adapters

Relayer Context

Adapters receive solver-specific context data appended to calldata:
AdapterBase.sol

Calldata Format

The Router appends relayer context to adapter calldata:
Example Usage:
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:

Adapter Tags

Adapters can specify metadata tags for routing behavior:
  • 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 functions

Trusted 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 supportsInterface

Gas Optimizations

Adapters can optimize gas usage:

Arbiters

Learn about arbiter layer and resource unlocking

Router System

Understand how Router coordinates adapters