Table of Contents
Fetching ...

Optimal Routing in the Presence of Hooks: Three Case Studies

Tarun Chitra, Kshitij Kulkarni, Karthik Srinivasan

TL;DR

This paper addresses optimal routing of user trades in networks of constant function market makers (CFMMs) in the presence of hooks, which enable auxiliary data to influence trade outputs. It develops tractable formulations based on convex optimization and dynamic programming to handle three practical hook scenarios: onchain limit orders, time-weighted liquidity via TWAMMs, and non-composable hooks with fill risk. The authors show that limit orders act as concentrated liquidity at a price tick, TWAMM-like strategies can be outperformed by mispricing-aware liquidations, and mean-variance analysis can quantify tradeoffs when non-composable hooks are involved, providing efficient frontiers for decision-making. The results demonstrate how hooks expand the routing design space while preserving computational tractability, offering practical guidance for deploying hooks in CFMM ecosystems and informing future adaptive routing approaches.

Abstract

We consider the problem of optimally executing a user trade over networks of constant function market makers (CFMMs) in the presence of hooks. Hooks, introduced in an upcoming version of Uniswap, are auxiliary smart contracts that allow for extra information to be added to liquidity pools. This allows liquidity providers to enable constraints on trades, allowing CFMMs to read external data, such as volatility information, and implement additional features, such as onchain limit orders. We consider three important case studies for how to optimally route trades in the presence of hooks: 1) routing through limit orders, 2) optimal liquidations and time-weighted average market makers (TWAMMs), and 3) noncomposable hooks, which provide additional output in exchange for fill risk. Leveraging tools from convex optimization and dynamic programming, we propose simple methods for formulating and solving these problems that can be useful for practitioners.

Optimal Routing in the Presence of Hooks: Three Case Studies

TL;DR

This paper addresses optimal routing of user trades in networks of constant function market makers (CFMMs) in the presence of hooks, which enable auxiliary data to influence trade outputs. It develops tractable formulations based on convex optimization and dynamic programming to handle three practical hook scenarios: onchain limit orders, time-weighted liquidity via TWAMMs, and non-composable hooks with fill risk. The authors show that limit orders act as concentrated liquidity at a price tick, TWAMM-like strategies can be outperformed by mispricing-aware liquidations, and mean-variance analysis can quantify tradeoffs when non-composable hooks are involved, providing efficient frontiers for decision-making. The results demonstrate how hooks expand the routing design space while preserving computational tractability, offering practical guidance for deploying hooks in CFMM ecosystems and informing future adaptive routing approaches.

Abstract

We consider the problem of optimally executing a user trade over networks of constant function market makers (CFMMs) in the presence of hooks. Hooks, introduced in an upcoming version of Uniswap, are auxiliary smart contracts that allow for extra information to be added to liquidity pools. This allows liquidity providers to enable constraints on trades, allowing CFMMs to read external data, such as volatility information, and implement additional features, such as onchain limit orders. We consider three important case studies for how to optimally route trades in the presence of hooks: 1) routing through limit orders, 2) optimal liquidations and time-weighted average market makers (TWAMMs), and 3) noncomposable hooks, which provide additional output in exchange for fill risk. Leveraging tools from convex optimization and dynamic programming, we propose simple methods for formulating and solving these problems that can be useful for practitioners.

Paper Structure

This paper contains 40 sections, 25 equations, 13 figures, 1 table.

Figures (13)

  • Figure 1: Decentralized exchange trades by number of pools touched danning.
  • Figure 2: Trading set, $\tilde{T} = \{z \in \mathbf{R}^2 \mid z^2 \leq p_0 z^1, z^2 \leq V_0, z^1, z^2 \geq 0\}$, for $p_0= 0.5$, $V_0 = 2$.
  • Figure 3: Comparison of the forward exchange function of a CFMM with and without a limit order. The output with the limit order creates a linear segment at the limit price $p_0$, followed by a continuation of the CFMM's forward exchange function.
  • Figure 4: Visualization of a limit order as a concentrated liquidity position. The sequence of blue rectangular functions with increasing height and decreasing width approaches a delta function representing a limit order at price $p_0$, with volume $V_0$. Darker shades of blue indicate more concentrated liquidity positions.
  • Figure 5: The CFMM Pigou network with limit orders.
  • ...and 8 more figures