This guide walks you through integrating as a solver or relayer with the Warp Router system. You’ll learn how to execute fill and claim operations, manage solver context, and optimize for gas efficiency.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
The Warp Router enables solvers to execute atomic operations across multiple protocols through a modular adapter system. As a solver, you’ll interact with the Router contract to:- Execute fill operations to fulfill user orders
- Process claim operations to unlock user resources
- Provide solver context to configure settlement behavior
- Optimize gas costs through batch operations
Understanding the Router Architecture
The Router uses a delegatecall-based adapter pattern: Key Concepts:- The Router is located at
src/router/Router.sol:102 - All adapter calls are executed via delegatecall in the Router’s context
- Fill operations require atomic signatures for security
- Claim operations rely on protocol-level authorization
Executing Fill Operations
Fill operations settle user orders by transferring assets. They require cryptographic signatures from the Router’s atomic signer.Standard Fill Route
Prepare solver context
Create your solver context based on the adapter’s requirements. For SameChainAdapter:See Solver Context for details on context formats.
Optimized Batch Fill
Theoptimized_routeFill921336808 function provides 20-40% gas savings for batch operations through adapter caching and optimized encoding.
Prepare solver contexts
Create one context per regular adapter call:
Special selectors (singleCall, multiCall) don’t consume solver contexts, so only include contexts for regular adapter calls.
- Adapter Caching: Consecutive calls with the same selector save ~2100 gas per reuse (from
RouterLogic.sol:250-257) - Encoded Calldata: Direct calldata access saves ~200-500 gas per element (from
RouterLogic.sol:160-162) - Special Selectors: Built-in operations bypass adapter lookup, saving ~2600+ gas (from
RouterLogic.sol:171-172)
Executing Claim Operations
Claim operations unlock user resources from protocols like TheCompact or Permit2. They don’t require atomic signatures since authorization is handled at the protocol level.Single Claim
Batch Claims
Process multiple claims atomically:RouterLogic.sol:331, batch claims use the same caching optimizations as fills.
Special Selectors
The Router supports special selectors that bypass adapter lookup for maximum efficiency:singleCall: Direct contract interactionmultiCall: Batched contract interactions- Fee collection operations
Error Handling
Common Errors
InvalidAtomicity (from RouterLogic.sol:201)
- The atomic signature is invalid or from an unauthorized signer
- Ensure your signature is from the Router’s configured
$atomicFillSigner
LengthMismatch (from RouterLogic.sol:292)
- Solver contexts don’t match the number of regular adapter calls
- Remember: special selectors don’t consume contexts
AdapterCallFailed (from RouterLogic.sol:272)
- The adapter call reverted or returned wrong selector
- Check that your calldata is properly formatted
- Verify adapter requirements are met
AtomicSignerNotSet (from RouterLogic.sol:150)
- The Router’s atomic signer is set to address(0)
- The Router is paused for fill operations
Best Practices
Gas Optimization
- Batch Similar Operations: Group operations using the same adapter to leverage caching (saves ~2100 gas per cache hit)
- Use Optimized Routes: Always use
optimized_routeFill921336808for production batches - Minimize Context Size: Keep solver context data as compact as possible to reduce calldata costs
- Leverage Special Selectors: Use built-in operations when possible
Security
- Signature Management: Protect the atomic signer’s private key - it controls all fill operations
- Context Validation: Ensure solver context matches adapter expectations
- Batch Atomicity: Remember that all operations in a batch succeed or revert together
- Gas Limits: Account for gas stipends in pre-claim operations
Integration Testing
Next Steps
Solver Context
Learn about solver context formats for different adapters
Building Adapters
Create custom adapters for new protocols
Deployment
Deploy and configure the Router system