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 Router is the central entry point for all settlement operations in the Warp Router ecosystem. It orchestrates cross-chain settlement operations and protocol integrations through a flexible adapter architecture.The Router contract is deployed at a deterministic storage layout position to ensure predictable deployment and integration patterns across chains.
Architecture
The Router system consists of three main components:Router
Main entry point contract that inherits all functionality
RouterLogic
Core routing logic for fill and claim operations
RouterManager
Adapter lifecycle management with role-based access control
Router Contract
TheRouter contract serves as the primary entry point with a deterministic storage layout:
Router.sol
The custom storage layout position ensures that state variables occupy predictable storage slots across deployments, enabling advanced patterns like proxy-based upgrades.
RouterLogic
RouterLogic implements the core routing functionality for all settlement operations:RouterLogic.sol
- Operation Routing - Routes fill and claim operations to appropriate protocol adapters
- Atomic Execution - Ensures batched operations execute atomically or revert entirely
- Gas Optimization - Implements advanced caching and optimization techniques
- Security Enforcement - Validates signatures and prevents unauthorized operations
- Context Management - Manages solver-specific contexts for each operation
RouterManager
RouterManager handles the adapter lifecycle with semantic versioning:RouterManager.sol
- Install Adapters
- Hotfix Adapters
- Retire Adapters
Atomic Fill Security
The Router uses an atomic fill signer to authorize batch operations:RouterLogic.sol
- Single Authorized Signer - Only the designated signer can authorize fill batches
- Replay Protection - Signatures are bound to specific calldata via hash
- ECDSA Recovery - Efficient signature verification without public key input
- Pausable - Setting signer to zero address pauses fills
Operation Flow
Gas Optimizations
The Router implements several gas optimization techniques:Adapter Caching
RouterLogic.sol
Optimized Route Fill
Theoptimized_routeFill921336808 function provides enhanced performance:
RouterLogic.sol
- Encoded Calldata Format - Reduces calldata costs by ~200-500 gas per element
- Adapter Caching - Reuses cached addresses for consecutive same-selector calls
- Special Selector Bypass - Built-in selectors skip adapter lookup entirely
- Inline Assembly Decoding - Operates directly on calldata without memory copying
Gas Savings Breakdown
Gas Savings Breakdown
- Adapter Cache Hit: ~2,100 gas (avoids cold SLOAD)
- Special Selector: ~2,600+ gas (avoids SLOAD + DELEGATECALL overhead)
- Encoded Calldata: ~200-500 gas per operation
- Assembly Decoding: Saves memory expansion and copying costs
Role-Based Access Control
The Router uses OpenZeppelin’s AccessControl for adapter management:| Role | Address | Capabilities |
|---|---|---|
| ADD_ROLE | adder | Install new adapters, apply hotfixes, set atomic fill signer, pause router |
| RM_ROLE | remover | Retire problematic or deprecated adapters |
RouterManager.sol
Configuration
Deployment Parameters
Address authorized to sign atomic fill batches. Must be non-zero for fills to function. Consider using hardware wallet or multi-sig.
Address granted
ADD_ROLE for registering new protocol adapters. Should be a secure governance address.Address granted
RM_ROLE for disabling compromised adapters. Should be a secure operations address.Example Deployment
Security Considerations
Related Concepts
Adapters
Learn about the adapter architecture and delegatecall pattern
Fill & Claim
Understand fill and claim operation types