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
SameChainAdapter orchestrates same-chain order settlement within the Warp Router ecosystem. This adapter handles cases where both order origin and execution occur on the same blockchain, eliminating cross-chain complexity while maintaining proper settlement guarantees through pre-funding and coordinated arbiter execution.
Source: src/arbiters/samechain/SameChainAdapter.sol
Inherits: AdapterBasePrefund, SameChainArbiter
Settlement Architecture
Same-chain orders provide efficiency benefits by avoiding cross-chain coordination overhead. The settlement follows this critical 3-step process:- PRE-FUNDING: Solver pre-funds the recipient with output tokens before claiming input tokens
- RESOURCE UNLOCK: Arbiter validates signatures and unlocks user’s input resources
- TARGET EXECUTION: Final operations (swaps, transfers) are executed on behalf of the user
Dual Protocol Support
This adapter supports both Compact and Permit2 protocols with different data requirements:- Compact Protocol: Full featured with pre-claim operations, gas stipends, and allocator data
- Permit2 Protocol: Streamlined flow with simplified signature requirements
Security Model
- Access Control: Only Router can call fill functions (onlyViaRouter modifier)
- Pre-funding Safety: Recipients receive output tokens before input tokens are unlocked
- Atomic Settlement: If any step fails, the entire transaction reverts
- Signature Validation: All user signatures validated by the arbiter before execution
- Nonce Protection: Each order has unique nonce to prevent replay attacks
Data Structures
FillDataCompact
The complete order specification including tokens, operations, and metadata. Contains sponsor, recipient, nonce, deadlines, token amounts, and target operations.
Container for all required signatures (notarized claim sig and optional pre-claim sig). Signatures are validated by the arbiter to ensure user authorization.
Array of hashes for multi-element orders (empty for single-element same-chain orders). Used in complex multi-chain scenarios but typically empty for same-chain settlements.
Protocol-specific data for the Compact allocator contract. Contains parameters needed for resource allocation and validation.
FillDataPermit2
The complete order specification including tokens, operations, and metadata. Same structure as Compact but typically with simpler target operations.
Container for required signatures, primarily the notarized claim signature. Permit2 typically requires fewer signatures than full Compact protocol.
Constructor
The Router contract address that will delegatecall this adapter. Must be a valid Router deployment with same-chain adapter support.
The Compact protocol contract address for handling Compact-based orders. Used for full-featured same-chain settlements with pre-claim operations.
The SameChainArbiter contract address that processes settlement logic.
The address book contract containing protocol addresses and configurations.
Fill Functions
samechain_compact_handleFill
The Compact protocol provides full-featured order execution including:
- Pre-claim operations (approvals, setup calls)
- Gas stipend allocation for complex operations
- Allocator data for protocol-specific validation
- Multi-signature support for complex authorization flows
Complete Compact protocol order data including signatures and metadata. Contains all information needed for settlement validation and execution.
This function’s selector for Router IERC165 interface compliance. Enables Router to verify adapter capabilities before execution.
- Pre-funds recipient with output tokens
- Calls arbiter to validate and unlock resources
- Emits
RouterFilledevent - Returns function selector
this.samechain_compact_handleFill.selector
samechain_permit2_handleFill
The Permit2 protocol focuses on:
- Simplified signature requirements
- Lower gas costs for basic operations
- Direct token authorization via Permit2 contract
- Streamlined validation and execution flow
Permit2 protocol order data with essential signatures and order details. Contains simplified data structure optimized for efficient processing.
This function’s selector for Router IERC165 interface compliance.
- Pre-funds recipient with output tokens
- Calls arbiter to validate and unlock resources
- Emits
RouterFilledevent - Returns function selector
this.samechain_permit2_handleFill.selector
Gas Optimization: More gas-efficient than Compact protocol for simple token operations.
Internal Functions
_tokenInRecipient
abi.encodePacked(address(recipient)) (20 bytes)
Returns:
The address where input tokens should be sent after arbiter processing. This is typically the solver’s address or a solver-controlled contract.
_handleCompactFill
- PRE-FUNDING PHASE: Transfers output tokens from solver to recipient
- ARBITER COORDINATION: Calls SameChainArbiter with order data and signatures
- EVENT EMISSION: Emits Filled event for off-chain tracking
Complete Compact order data including signatures, allocator data, and gas stipend
Address where input tokens will be sent after arbiter processes the unlock. Typically the solver’s address or a solver-controlled withdrawal contract.
_handlePermit2Fill
Permit2 order data with simplified structure focused on essential settlement info
Address where input tokens will be deposited after successful validation. Receives tokens directly from Permit2 unlock without intermediate steps.
Interface Support
supportsInterface
The function selector to check for support
True if the selector is supported by this adapter. Returns true for:
samechain_compact_handleFill.selectorsamechain_permit2_handleFill.selector- Any selectors supported by AdapterBase
- Any selectors supported by ArbiterBase
Events
RouterFilled
The address that sponsored the order
The unique nonce of the filled order
Relayer Context
The relayer data must be encoded as:recipient is the address that should receive the tokenIn payment. This address will be passed to the arbiter as the depositor for input tokens.
Length: Exactly 20 bytes
Security Considerations
- Only callable via Router delegatecall (enforced by
onlyViaRouter) - All user signatures validated by arbiter before token movements
- Atomic execution ensures either complete success or complete revert
- Nonce system prevents replay attacks
Gas Optimization
Same-chain operations are optimized for lower gas costs compared to cross-chain alternatives, with efficient pre-funding and single-transaction settlement. Permit2 variant provides additional gas savings for simple operations.Related Contracts
- AdapterBase - Base adapter functionality
- SameChainArbiter - Settlement validation and execution