01Executive Summary
JIL Sovereign's execution router evaluates every trade intent against a seven-rule precedence chain that considers the current market state, entity toxicity score, order size, and entity-specific routing preferences to determine whether the intent should be executed via the retail batch auction lane or the request-for-quote (RFQ) lane. Each lane has distinct fee structures, execution mechanics, and risk profiles.
The routing decision is deterministic and transparent: the same inputs always produce the same routing decision, and the specific rule that determined the routing is logged with every intent. The router fetches the current market state from the market-state service with a 2-second timeout and fails open to NORMAL, ensuring that routing continues even if the state service is temporarily unavailable.
02Problem Statement
Decentralized exchanges typically offer a single execution venue - a constant-product AMM pool - with no ability to route orders to different execution mechanisms based on market conditions, order characteristics, or entity risk profiles. This one-size-fits-all approach means that large institutional orders, small retail trades, and toxic flow all execute through the same mechanism, leading to suboptimal outcomes for all participants.
2.1 Routing Challenges
- Size Mismatch: Large orders create excessive slippage in AMM pools designed for retail-sized trades, while RFQ mechanisms are too heavyweight for small orders.
- Market Conditions: During stressed market conditions, AMM pools may have insufficient liquidity, and routing all flow through them amplifies price impact. RFQ provides better execution during stress.
- Toxic Flow: Routing informed traders through the same pool as retail traders causes systematic LP losses. Toxic flow should be segregated to venues where market makers can price it appropriately.
- Fee Transparency: Different execution venues have different cost structures, but users often cannot see or compare fees before execution.
2.2 Why Existing Approaches Fail
| Approach | Routing Logic | State Awareness | Limitation |
|---|---|---|---|
| Uniswap (Single Pool) | None - all flow to pool | None | No routing at all |
| 1inch Aggregator | Best price across venues | None | Price-only, no state/toxicity factors |
| CoW Protocol | Solver competition | Limited | Solver chooses, not protocol |
| Hashflow RFQ | All flow to market makers | None | No retail lane option |
03Technical Architecture
The execution router processes each trade intent through a seven-rule precedence chain. Rules are evaluated in strict order, and the first matching rule determines the routing decision. This precedence ensures that safety rules (HALTED, BLOCKED) always take priority over economic rules (size, preferences).
3.1 Seven-Rule Precedence Chain
| Priority | Rule | Condition | Action | Rationale |
|---|---|---|---|---|
| 1 | HALTED | Market state = HALTED | REJECT | No trading during market halt |
| 2 | BLOCKED | Entity toxicity = CRITICAL | REJECT | Blocked entities cannot trade |
| 3 | SIZE | Order size >= RFQ minimum | RFQ | Large orders get better execution via RFQ |
| 4 | STRESSED | Market state = STRESSED | RFQ | RFQ-first during market stress |
| 5 | HEAVY | Entity toxicity = HIGH | RFQ + deposit | Toxic flow segregated with collateral |
| 6 | RFQ_PRIORITY | Entity prefers RFQ | RFQ | Respect institutional routing preference |
| 7 | DEFAULT | No prior rule matched | RETAIL | Standard retail batch auction |
3.2 Fee Structure by Lane
| Fee Component | Retail Lane | RFQ Lane | Description |
|---|---|---|---|
| DEX Fee (Buyer) | 1.00% | 1.00% | Standard buyer-side trading fee |
| DEX Fee (Seller) | 1.00% | 1.00% | Standard seller-side trading fee |
| Settlement Fee | 4 bps | 4 bps | Settlement processing cost |
| RFQ Routing Fee | N/A | 10 bps | Additional fee for RFQ lane access |
| Total (Buyer) | 1.04% | 1.14% | All-in buyer cost |
| Total (Seller) | 1.04% | 1.14% | All-in seller cost |
3.3 Fail-Open Market State Fetch
The router fetches the current market state via HTTP with a strict 2-second timeout. If the market-state service is unreachable or does not respond within 2 seconds, the router defaults to NORMAL state and continues routing. This fail-open design ensures that a market-state outage never halts trading. The fallback is logged for monitoring, and the AI Fleet Inspector tracks market-state availability separately.
04Implementation
4.1 Preview vs Execute
The router exposes two endpoints: POST /v1/router/preview and POST /v1/router/execute. The preview endpoint evaluates the routing rules and returns the routing decision, fees, and the specific rule that determined the routing without recording anything to the database. This allows users to see their routing and fees before committing. The execute endpoint performs the same evaluation and additionally records the intent in the router_intents table.
4.2 Routing Decision Record
Every executed routing decision is recorded with: the intent ID, entity ID, market state at decision time, toxicity tier, order size, the matching rule number and name, the resulting lane (RETAIL/RFQ/REJECT), calculated fees, and timestamp. This comprehensive audit trail enables post-hoc analysis of routing quality and fairness.
4.3 Per-Pair Configuration
Routing parameters are configurable per trading pair via the router_config table. Each pair can have different RFQ minimum size thresholds, different fee rates, and different toxicity-dependent routing rules. Pre-seeded configurations cover JIL/USDC, JIL/ETH, jBTC/jUSDC, and jETH/jUSDC.
4.4 Intent Lifecycle
After routing, intents follow the lifecycle: PENDING (recorded by router) to ROUTED (sent to the target lane) to FILLED, PARTIALLY_FILLED, or REJECTED (by the clearing engine). The router tracks the intent through its lifecycle via status callbacks from the retail lane engine or RFQ service.
05Integration with JIL Ecosystem
5.1 Market State Service (Claim 30)
The router depends on the hysteresis market state machine for real-time state information. HALTED and STRESSED states directly affect routing decisions through rules 1 and 4 of the precedence chain. The fail-open fallback to NORMAL ensures that market-state outages do not cascade to routing failures.
5.2 Entity Toxicity Scoring (Claim 33)
The router fetches the entity's toxicity tier from the scoring engine. CRITICAL toxicity triggers rule 2 (BLOCKED), HIGH toxicity triggers rule 5 (HEAVY - RFQ with deposit). Toxicity scoring and routing work together as a graduated defense system: the scoring engine classifies entities, and the router enforces the classification.
5.3 Retail Lane Engine (Claim 31/32)
Intents routed to the RETAIL lane are submitted to the retail lane engine's batch auction queue. They participate in VRF-shuffled batch clearing with iterative price discovery. The retail lane is the default for most retail-sized orders from non-toxic entities.
5.4 RFQ Service
Intents routed to the RFQ lane are forwarded to registered market makers for competitive quoting. Market makers return firm quotes that the entity can accept or reject. The 10 bps additional routing fee compensates for the operational overhead of the RFQ matching process.
06Prior Art Differentiation
| System | Routing Model | State Awareness | Toxicity Integration | JIL Advantage |
|---|---|---|---|---|
| Uniswap v3 | No routing - single pool | None | None | JIL routes to optimal lane per intent |
| 1inch | Best-price aggregation | None | None | JIL considers state + toxicity, not just price |
| Paraswap | Multi-DEX splitting | None | None | JIL routes to distinct execution mechanisms |
| CoW Protocol | Solver decides routing | Indirect | None | JIL uses deterministic protocol-level rules |
| Wintermute RFQ | All flow to market maker | None | None | JIL offers both retail and RFQ with smart routing |
07Implementation Roadmap
Core Router
Deploy seven-rule precedence chain with market state integration. Implement preview and execute endpoints. Build per-pair configuration with pre-seeded trading pairs. Create intent lifecycle tracking with status callbacks.
Toxicity Integration
Wire entity toxicity scoring into rules 2 and 5. Implement deposit requirement for HIGH toxicity RFQ routing. Build routing analytics dashboard showing lane distribution by toxicity tier. Calibrate toxicity thresholds for routing decisions.
Advanced Lane Selection
Dynamic RFQ minimum size based on market conditions. Multi-lane splitting for very large orders (partial retail + partial RFQ). Cross-pair routing optimization for multi-leg trades. Latency optimization for routing decision path.
Best Execution Proof
On-chain routing decision proofs for regulatory compliance. Post-trade analysis comparing actual vs. alternative lane outcomes. Best execution reports for institutional clients. Third-party audit of routing fairness and determinism.