Decentralised News · 2027 planning series · Reviewed 21 November 2026
A swap can receive a better pool price and still be a worse transaction after network costs. That is the useful starting point for evaluating an AI router: how much extra output does another route produce, and how much does activating that route cost?
The answer changes with order size, reserves, fees and the permitted pools. It also changes before a transaction executes. This article builds a two-pool model that makes the trade-off visible, then explains where its assumptions stop describing a real routing problem.
What Matters
Splitting an exact-input swap can reduce the price impact of concentrating the whole order in one pool. The improvement must exceed the additional execution costs. Compare amounts in the same output-token unit, include pool fees once, and distinguish estimated gas-adjusted output from tokens actually received. A larger route graph or a team of learning agents does not by itself improve that comparison.
The Signal
Uniswap’s current routing explanation describes eligible pools, intermediate tokens, splitting, network-cost awareness and simulation. Its Smart Order Router repository also makes split routing and gas-adjusted quotations explicit. These are established routing mechanisms. They are useful baselines for an AI proposal, rather than evidence that multi-agent reinforcement learning dominates execution.
DN Alpha Thesis
The economic value of a more complicated route is its incremental net output under the same constraints. Measure the improvement against the strongest eligible simple alternative. That creates a concrete engineering budget: how much additional gas, quotation work and operational complexity can the proposed route consume before its advantage disappears?
Define the order before choosing the algorithm
Our decision is an exact-input exchange of one token for another on one chain. The input amount is fixed; the objective is to maximize output after separately declared execution costs. An exact-output order reverses the question: the desired receipt is fixed and the router seeks the required input. Uniswap’s pricing documentation distinguishes those cases and warns against treating an unprotected reserve observation as an acceptable execution price.
The two pools must contain the same assets in the same direction. An input reserve denominated in Token X cannot be compared with a reserve of wrapped Token X on another chain without additional assumptions. The output token also needs one consistent unit. Decimal scaling mistakes can make a small pool appear enormous or a network charge appear negligible.
Keep the permitted venue set fixed. A router allowed to use a disputed token, an unsupported hook or an unavailable pool has a different problem from a router forbidden to use it. A comparison that quietly grants one candidate more venues attributes eligibility differences to intelligence.
DN’s route-fragmentation and settlement ledger handles the later reconciliation of quotes, transactions and completed routes. Here the narrower question is how to allocate a proposed input across two eligible pools.
Why one pool becomes more expensive at the margin
For a simple constant-product pool, let X be its input-token reserve, Y its output-token reserve, q the proposed input and f its input-side swap fee as a fraction. Write a = 1 − f. The idealized output is:
output(q) = Y × a × q ÷ (X + a × q)
The fee reduces the input used in the pricing calculation. As q grows, the denominator grows too. Doubling the order therefore produces less than twice the output. The next unit receives a worse exchange rate than the first, even when the external market has not moved.
The official Uniswap v2 library implements this relationship with integer arithmetic and its specified fee factor. DN generalizes the fee input for a synthetic constant-product model. A real contract’s fee rules, integer rounding and token behavior must be reproduced separately; ordinary browser arithmetic is unsuitable for generating transaction amounts.
Fees and price impact are already incorporated in this calculated output. Subtracting an additional percentage for the same swap fee would charge it twice. External execution costs remain separate because they are not contained in the pool formula.
The model also assumes ordinary transfers and unchanged reserves during calculation. Transfer taxes, rebasing, callbacks, shared state and custom accounting can invalidate that description. A pair of reserve numbers is a model input, not proof that a token or pool is executable.
Splitting works by equalizing the next unit’s output
Suppose qA goes to Pool A and the remaining Q − qA goes to Pool B. Before external costs, combined output is the sum of the two pool formulas. Sending everything to A may push its marginal exchange rate below B’s. Moving a small part of the order to B can then increase the total receipt.
For this model, marginal output is:
marginal(q) = a × X × Y ÷ (X + a × q)²
An interior allocation maximizes combined output when the pools offer equal marginal output for the next input unit. If one pool remains better even after receiving the entire order, the gross optimum is an endpoint: use that pool alone. Splitting is not mandatory.
The DN worksheet checks the two endpoints and uses a bounded bisection search for an interior solution. Because each output curve is concave, the marginal difference moves in one direction as input shifts between these two independent pools. This is a deterministic calculation for a deliberately small problem.
The wider distinction appears in Angeris and colleagues’ routing research: their formulation can be convex without fixed execution costs, while including fixed costs introduces a discrete venue-activation problem. DN’s two-pool worksheet illustrates that boundary; it does not implement the paper’s general network optimizer.
Different starting prices change when a second pool helps
Reserve depth alone is insufficient when the pools begin at different exchange rates. Suppose Pool A instead holds 100,000 X and 105,000 Y, while Pool B still holds 50,000 of each token. With equal fees, A initially offers more Y for each additional X. Sending a small order partly to B would surrender some of that advantage.
In this altered synthetic case, the gross allocation remains entirely in A until its marginal output falls to B’s initial marginal output. Solving the derivative equality gives a crossover near 2,477 X before any external execution cost is considered. A second pool becomes useful at the margin only beyond that point. Its fixed activation cost can delay the net-beneficial split further.
This distinction explains why proportional allocation is confined to the equal-price worked example below. A shallow pool with an attractive initial price may deserve a small allocation; a deep pool with an unfavorable price may deserve none. The reserve ratio establishes the starting exchange rate, while the reserve scale determines how quickly that rate deteriorates.
The worksheet therefore searches using each pool’s separate fee and reserve pair. It does not assume equal initial prices, impose a 50/50 split, or allocate merely in proportion to displayed liquidity. A boundary result is a valid answer, not a failure to find enough routes.
The extra route has an activation cost
Let GA and GB be the total external costs of the two single-pool alternatives. Let GS be the total external cost of the split transaction. All three are expressed in output-token equivalents under the same conversion convention.
net A = outputA(Q) − GAnet B = outputB(Q) − GBnet split = best gross split output − GS
GS is the entire split-route charge, not a surcharge added to GA again. Shared transaction overhead can make it different from GA + GB. Include whatever distinct execution costs the stated comparison requires, while preserving their original native-asset amounts in the supporting record.
The worksheet assumes that activating both pools does not make the total external charge lower than either corresponding one-pool charge. A subsidy, rebate or size-dependent execution discount that breaks this assumption needs a different cost model. Such inputs are rejected here instead of producing an unsupported optimum.
The split’s maximum total external-cost budget is its gross output minus the better single-pool net result. If the proposed split cost exceeds that budget, the simple alternative wins within the model. This threshold is more informative than saying that another venue improves the quote.
Gas-adjusted output is an economic comparison. It is not necessarily the wallet’s received-token balance: the network fee may be paid in another asset. If that asset’s conversion rate changes, the comparison changes even when the pool outputs do not.
A larger synthetic order pays for the second pool
Consider two invented Token X/Token Y pools. Pool A holds 100,000 X and 100,000 Y. Pool B holds 50,000 X and 50,000 Y. Both charge 0.30%. The order supplies 10,000 X. These are constructed reserves and costs, not observations of named pools.
| Candidate | Input allocation | Gross Y output | External cost in Y equivalents | Net Y equivalent |
|---|---|---|---|---|
| Pool A only | 10,000 to A | 9,066.11 | 8.00 | 9,058.11 |
| Pool B only | 10,000 to B | 8,312.49 | 8.00 | 8,304.49 |
| Two-pool split | 6,666.67 to A; 3,333.33 to B | 9,348.63 | 18.00 | 9,330.63 |
Equal starting prices and equal fees make the gross-optimal split proportional to reserve depth in this particular example. That proportion is not a universal routing rule. Change a fee or starting reserve ratio and the optimal allocation can shift substantially.
The split improves gross output by about 282.52 Y relative to A. Its extra external cost is 10 Y, leaving a modeled advantage of 272.52 Y equivalents. Its total external-cost budget before tying the better single-pool route is approximately 290.52 Y equivalents.
None of these numbers establishes an arbitrage profit. The trader exchanges X for Y; the assets differ. The calculation compares ways to fulfill the same exchange, without valuing the input in another currency or predicting a later sale.
A smaller order reverses the result
Reduce the input to 1,000 X while keeping the invented reserves, fees and route costs unchanged. Pool A produces approximately 987.16 Y. The gross-optimal split produces 990.42 Y. The improvement is only 3.26 Y, because the smaller order creates less pressure on Pool A’s reserves.
After the same external costs, A provides 979.16 Y equivalents and the split provides 972.42. The single-pool route leads by approximately 6.74. The split’s total cost budget is only 11.26 Y equivalents, below the assumed 18-unit charge.
This reversal is the practical reason to test multiple order sizes. A routing technique that is valuable for a large order can be uneconomic for a small one. A percentage improvement calculated before gas hides the fixed-cost burden.
For a real quote, do not carry the large-order network estimate over automatically. Execution paths, storage access and other chain-specific charges can differ. The example holds costs fixed solely to isolate the size effect.
Real routing changes the feasible set
Uniswap v3 and v4 concentrated liquidity cannot generally be modeled by dropping aggregate token balances into this two-reserve formula. Active ranges and movement across ticks affect the output function. Different pool types require their own quotation method.
In v4, dynamic LP fees may be updated through PoolManager or a before-swap hook. They are distinct from protocol and optional hook fees. A fee is therefore part of a versioned pool configuration and quotation context, not necessarily a permanent number attached to a token pair.
The current app routing documentation also restricts eligibility, including how certain hooks and blocked pools are treated. The mathematical best route across every pool someone can discover may not be available through a particular interface. Record the actual route universe when comparing implementations.
Multi-hop paths introduce intermediate assets and additional state. Shared pools cannot be quoted independently and then added as though both trades saw untouched reserves. Cross-chain movement adds separate completion and inventory questions. Those are extensions of the problem, not switches in this worksheet.
Where multi-agent learning has a defensible role
Multi-agent reinforcement learning concerns policies learned from rewards in interacting environments. A collection of researcher, trader and auditor language-model prompts does not automatically constitute MARL. DN’s trading-team architecture guide addresses that different organizational design.
Lowe and colleagues’ multi-agent actor-critic paper studies coordination and the difficulties created when other agents change the learning environment. Its experiments do not demonstrate dominance in public DeFi routing. A liquidity-routing claim needs evidence from the actual market problem being claimed.
A plausible learned component might decide which expensive quote to request next, how much search time to spend, or when a changing environment warrants recalculation. Its value would depend on the information and computation it saves while preserving eligible execution quality. For two fully specified pools at a fixed snapshot, a transparent numerical solution provides a strong reference without training a policy.
A reward based only on gross output can teach a system to activate too many routes. A reward based only on successful trades can hide failed submissions. A reward measured before a destination receives funds can reward an unfinished process. The objective should represent the user’s actual completed task, and comparisons should retain rejected or unsuccessful attempts.
Price impact, slippage and stale state
Uniswap’s glossary separates price impact caused by trade size from differences between expected and actual execution prices. A generous slippage tolerance does not make a route efficient; it permits a wider execution outcome.
The model uses one frozen state. Between quotation and execution, other transactions can change reserves, fees or eligibility. An apparent split advantage of a few output units can disappear before inclusion. Compare quotes from a consistent observation and retain their time or block context.
The official quote API reference describes route information, estimated gas and simulation behavior. Simulation is useful evidence about a proposed call under the simulated conditions. It is not a receipt for a completed trade or a guarantee of future network cost.
After an actual execution, compare the completed route with the declared objective using the settlement ledger. Keep quoted output, actual receipt and external charges separate. Otherwise, a routing improvement can be credited to favorable market movement or concealed by a mismatched fee conversion.
Use the DN Two-Pool Split and Gas Model
Enter two positive reserve pairs, one input amount, the two fee percentages and total external costs for each candidate. The worksheet reports gross and net-equivalent outputs, the modeled split and the split’s total-cost ceiling. Blank inputs remain unresolved. It does not fetch reserves, estimate gas, connect a wallet or submit a transaction.
DN Two-Pool Split and Gas Model
Change the illustrative assumptions below. This worksheet runs locally in your browser. It records your declarations; it does not verify evidence, connect to accounts, submit instructions or grant approval.
The initial numbers are synthetic. Unknown evidence remains unresolved. Downloads contain the values you enter; use aliases and avoid private or identifying information.
Methodology and practical limits
DN reviewed the linked primary sources on 21 November 2026 and compared this scope with its existing routing, liquidity-management and multi-agent architecture articles. The examples are synthetic. DN calculated their outputs and checked the worksheet’s arithmetic; no live pool quote, wallet execution or trained MARL policy was tested for this article.
The model assumes two independent constant-product pools, unchanged reserves, input-side proportional fees, ordinary transfers and constant external costs per candidate. It excludes concentrated liquidity, hooks, taxes on transfers, integer contract rounding, intermediate routes, adversarial ordering, quote-search expense and cross-chain execution. Its result is optimal only within that declared mathematical problem.
A useful next observation is the proposed route’s incremental output after its actual execution costs. If that difference is smaller than ordinary quotation variation, investigate before adding complexity. If it remains material, the next question is whether the eligible route can deliver it under the user’s execution constraints.
Sources and evidence register
Primary sources reviewed on 21 November 2026. The article distinguishes documented facts, DN analysis and synthetic examples. Recheck changeable rules and configurations before acting.
- Uniswap Labs: How routing works — Current pool eligibility, split routing, gas adjustment and simulation; interface-specific scope.
- Uniswap: Smart Order Router — Public routing implementation and gas-adjusted quote baseline; no DN live benchmark.
- Uniswap: v2 pricing — Exact-input/output distinction and the limitation of unprotected reserve-based execution.
- Uniswap: v2 library source — getAmountOut formula, specified fee factor and integer arithmetic.
- Angeris et al.: Optimal Routing for Constant Function Market Makers — General routing formulation and the effect of fixed execution costs; DN implements only its own small two-pool illustration.
- Uniswap: Dynamic Fees — Pool creation scope, fee updates, and distinction from protocol/hook fees.
- Lowe et al.: Multi-Agent Actor-Critic — Multi-agent learning and nonstationarity; not evidence of DeFi routing dominance.
- Uniswap: Protocol Glossary — Price impact, slippage and concentrated-liquidity terminology.
- Uniswap: Quote API reference — Route and estimated-gas information and simulation behavior; not settlement evidence.
Frequently asked questions
Does splitting a swap always improve the result?
It can improve gross pool output while losing after additional execution costs. The smaller synthetic order in this article shows that reversal.
Is the gas-adjusted result the amount of tokens my wallet receives?
Not necessarily. It subtracts external costs expressed in output-token equivalents. A network fee may be paid in a different asset, while the wallet receives the gross output amount.
Can I enter Uniswap v3 or v4 token balances into this calculator?
The model is for two independent constant-product pools. Concentrated liquidity, ticks, hooks and dynamic fees need their actual quotation logic; aggregate balances alone are insufficient.
Should pool fees be subtracted from the output again?
No. The worksheet formula already applies the entered input-side fee. Its separate cost fields are for charges outside that modeled pool output.
Does this establish that MARL beats a standard router?
No. It supplies a transparent mathematical baseline and synthetic scenarios. A MARL performance claim requires a specified implementation and comparable observed outcomes.
Can this tool generate an executable swap?
No. It uses browser arithmetic for a bounded comparison and does not fetch state, reproduce contract rounding, create calldata or authorize a trade.