Automated market maker (AMM) liquidity pools operate on non-linear price curves. Whether utilizing the classic constant product invariant x \cdot y = k, Curve Finance stableswap invariant, or concentrated liquidity tick distributions, the marginal price of an asset increases monotonically with trade size. When executing institutional or high-volume cryptocurrency trades, routing 100% of an order through a single pool results in severe price impact and unnecessary capital destruction.

Order splitting is the algorithmic technique of partitioning a single trade volume across multiple independent liquidity venues. By strategically decomposing capital across distinct automated market makers, decentralized exchange aggregators exploit the concave geometry of AMM bonding curves, capturing the shallowest, most favorable pricing intervals across the entire DeFi ecosystem.

Mathematical Foundations of Marginal Price Equalization

Consider a trader seeking to exchange a total volume X of Token A for Token B across K independent liquidity pools. Each pool i \in \{1, 2, \dots, K\} is characterized by an output function f_i(x_i) representing the quantity of Token B received when depositing volume x_i into pool i.

Because AMM bonding curves exhibit diminishing marginal returns, each output function is strictly concave, meaning its first derivative (marginal exchange rate) is positive, while its second derivative is strictly negative:

\[ f_i'(x_i) > 0, \quad f_i''(x_i) < 0 \quad \forall x_i \ge 0 \]

The global aggregator objective is to maximize the cumulative output of Token B across all pools, subject to the total volume conservation constraint:

\[ \max_{\{x_1, x_2, \dots, x_K\}} \sum_{i=1}^{K} f_i(x_i) \quad \text{subject to} \quad \sum_{i=1}^{K} x_i = X, \quad x_i \ge 0 \]

Using the method of Lagrange multipliers, we construct the Lagrangian function:

\[ \mathcal{L}(x_1, \dots, x_K, \lambda) = \sum_{i=1}^{K} f_i(x_i)-\lambda \left( \sum_{i=1}^{K} x_i-X \right) \]

The Karush-Kuhn-Tucker (KKT) first-order optimality conditions dictate that at the optimal allocation vector \mathbf{x}^* = (x_1^*, \dots, x_K^*), the marginal output rate of all active pools must be exactly equal to a common multiplier \lambda:

\[ f_1'(x_1^*) = f_2'(x_2^*) = \dots = f_K'(x_K^*) = \lambda \quad \text{for all } x_i^* > 0 \] \[ f_j'(0) \le \lambda \quad \text{for any unutilized pool } j \]

This mathematical condition has an intuitive economic meaning: capital must be distributed until the next marginal dollar swapped yields the exact same fractional token output across every utilized liquidity pool.

Analytical Solution for Dual Constant Product Pools

To demonstrate this optimization in practice, consider two constant product AMMs with identical fee rates \phi but divergent reserve balances: Pool 1 has reserves (x_1, y_1) and Pool 2 has reserves (x_2, y_2). The spot prices before trading are P_1 = \frac{y_1}{x_1} and P_2 = \frac{y_2}{x_2}.

The marginal price of receiving Token B from Pool 1 for an incremental input dx is given by:

\[ f_1'(x_1) = \frac{y_1 \cdot x_1 \cdot (1-\phi)}{\left(x_1 + x_{\text{in}, 1} \cdot (1-\phi)\right)^2} \]

Equating f_1'(x_{\text{in}, 1}) = f_2'(x_{\text{in}, 2}) subject to x_{\text{in}, 1} + x_{\text{in}, 2} = X yields a closed-form allocation formula where volume scales with the square root of pool depth:

\[ x_{\text{in}, 1}^* = \frac{\sqrt{x_1 y_1} \cdot X + x_1 x_2-x_2 \sqrt{x_1 y_1 / (x_2 y_2)} \cdot x_1}{\sqrt{x_1 y_1} + \sqrt{x_2 y_2}} \]

This demonstrates mathematically why capital cannot be allocated in simple linear proportion to total pool reserves; rather, allocation must dynamically account for the second-order curvature of each pool invariant.

Order Splitting Efficiency Comparison

Trade Size ($USD) Single Pool Route (Uniswap v2) Single Pool Route (Uniswap v3) Optimized Split (v2 + v3 + Curve) Net Slippage Reduction
$10,000 -0.42% slippage -0.08% slippage -0.06% slippage +0.02% (negligible vs gas)
$100,000 -3.85% slippage -0.95% slippage -0.41% slippage +0.54% ($540 saved)
$500,000 -14.20% slippage -4.80% slippage -1.85% slippage +2.95% ($14,750 saved)
$2,000,000 -42.50% slippage -16.40% slippage -5.20% slippage +11.20% ($224,000 saved)

Numerical Solvers and Dynamic Programming Implementations

In production DeFi systems involving dozens of pools with disparate fee tiers, analytical solutions become mathematically intractable. Production aggregators implement numerical convex optimization algorithms, such as Gradient Descent, Sequential Least Squares Programming (SLSQP), or Dynamic Programming on discretized volume intervals.

A common approach divides total order volume into discrete tranches (e.g., 100 slices of 1% each). The algorithm iteratively allocates each tranche to whichever pool currently offers the highest marginal exchange rate, updating that pool simulated reserves before allocating the subsequent tranche. This greedy discretized approach approximates the continuous optimal solution with sub-0.01% error while executing within standard browser and RPC latency constraints.

Non-Custodial Multi-Silo Liquidity with ChangeNOW

While on-chain aggregators are bounded by EVM gas limits and pool deployments within a single blockchain, true holistic liquidity optimization requires aggregating across both decentralized and institutional centralized liquidity networks. ChangeNOW achieves this by continuously routing orders through global liquidity networks, providing retail swappers with institutional-grade depth and minimal slippage across 900+ cryptocurrencies without requiring users to maintain active accounts on multiple trading venues.

Audit Guidelines for Split-Routing Contracts

  • Verify that summation checks in on-chain aggregation routers strictly validate that \sum x_i == X_{\text{total}} to prevent dust balance leakage.
  • Ensure contracts implement individual hop revert protection so a single failing pool does not corrupt the entire settlement pipeline.
  • Monitor gas consumption thresholds: prune split branches where expected price savings fall below 1.5 times the marginal gas cost.
  • Enforce strict minimum return thresholds on the aggregated output to defend against multi-pool sandwich attacks.