A formal-ish definition for Intents

A very simple intent that many end users seem to want is the easy swap: User holds x units of token A and wants to swap them for at least y units of token B.

Let’s formalize how a matching market for such an intent might function. There is a universe of n tokens, and m users who submit transactions of the form (x_{ij}, y_{ik}) where i= 1,\dots, m represents the users and j, k \in [n] \times [n] represent the token pairs. This is to be interpreted as: User i is requesting to provide x_{ij} units of token j for at least y_{ik} units of token k. For notational ease, we can therefore define two matrices: X \in \mathbb{R}^{m \times n} and Y \in \mathbb{R}^{m \times n} which are the input-output pairs that the users are requesting.

On the other side of the market are S solvers. These agents are responsible for filling the intents that the users satisfy. The way they do this is by engaging in transactions in a set of markets: decentralized exchanges, centralized exchanges, and other off-chain liquidity they might find. Each of these agents s =1,\dots, S posts an amount of liquidity \ell_{jk}^s(x) that they are willing to satisfy in each pair of tokens j,k. This is to be interpreted as the maximum amount of token k that solver s is willing to provide for receiving x units of token j.

We now define the matching matrix M \in \{0,1\}^{m \times S}, where M_{ij} = 1 if solver i is matched with user j and 0 otherwise. Given any matching, the amount of token k that user i receives over all solvers is given by \sum_{s=1}^{S} \ell_{jk}^s(x_{ij}) M_{is}

This allows us to set up the following optimization problem:

\begin{align*} \text{maximize } & u(M) \\ \text{subject to } & \sum_{s= 1}^{S} \ell_{jk}^s(x_{ij}) M_{is} \geq y_{ik} \text{ for all i} \\ \text{subject to } & 0 \leq \sum_{i=1}^{m} M_{is} \leq 1 \end{align*}

where the problem data are (X,Y) and \ell_{jk}^s(x), and the decision variable is the matching M, and the final constraint is that each solver is matched to at most one user. The utility function u(\cdot) could characterize any excess value that is transferred to the users above what their desired intent was. Note that we have converted the integer constraint M \in \{0,1\}^{m \times S} to final inequality constraint. Note that when x_{ij} =0, we want \ell_{jk}^s(x_{ij}) = 0, and therefore, the constraint is satisfied trivially.

Under certain conditions on the utility function, this problem may be cast as a convex optimization problem that can be efficiently solved, and whose optimality may be certified for any (X,Y).